Skip to content

LongExtensions Class ​

Definition ​

Extension methods for the long datatype

  • Namespace: JASE.Extensions
  • Assembly: JASE.Primitives.dll

Fields ​

NameDescription
FnvOffsetThe 64-bit FNV-1a offset basis value.
FnvPrimeThe 64-bit FNV-1a prime multiplier.

Methods ​

NameDescription
ByteSizeUnit BinaryUnit(long l)Returns the most appropriate unit for the value, based on thresholds.
bool CheckValue(long value, long valueFlag, int maxFlag = null)Checks if the specified flag is set in the bitmask based on a numeric value Verifies that valueFlag is a valid bitmask flag
ByteSizeUnit DecimalUnit(long l)Returns the most appropriate unit for the value, based on thresholds.
ulong Fnv1aCombine(ulong hash, IEnumerable<string> value)Combine an existing FNV-1a hash with an additional string value
ulong Fnv1aCombine(ulong hash, bool value)Combine an existing FNV-1a hash with an additional boolean value
ulong Fnv1aCombine(ulong hash, int value)Combine an existing FNV-1a hash with an additional integer value
ulong Fnv1aCombine(ulong hash, string value)Combine an existing FNV-1a hash with an additional string value
ulong Fnv1aCombine(ulong hash, ulong value)Combine an existing FNV-1a hash with an additional ulong value
string FormattedBinarySymbol(long l, int decimalPlaces = null, bool separators = null)Returns a formatted string with value and unit symbol.
string FormattedDecimalSymbol(long l, int decimalPlaces = null, bool separators = null)Returns a formatted string with value and unit symbol.
string FormattedUnitSymbol(long l, int decimalPlaces = null, bool separators = null)Returns a formatted string with value and unit symbol.
int GetFlag(long value, int maxFlag = null)Returns the Bitmask flag index for the input value
List<int> GetFlagIndices(long value)Returns a list of int's representing the bitmask indices that are set
List<int> GetFlags(long value)Returns a list of int's representing the bitmask flags that are set
int GetMaxBitIndex(long value)Returns the index position of the max bit set in the input value
int GetMaxBitValue(long value)Returns the value of the max bit set in the input value
bool IsFlagSet(long value, long flag, int maxFlag = null)Checks if a specific flag is set in the bitmask
bool IsPowerOf2(long value)Returns true if the input is a numeric power of 2
bool IsPowerOfTwo(long value)Returns true if the input is a numeric Power of 2
bool IsValidFlagValue(long input, int maxFlag = null)Returns true if the input is a valid flag value
long RemoveFlag(long value, int flag, int maxFlag = null)Remove a flag (turn the bit off)
long RemoveValue(long value, long valueFlag, int maxFlag = null)Remove a specified flag in the bitmask based on a numeric value Verifies that valueFlag is a valid bitmask flag and removes it
long SetFlag(long value, int flag, int maxFlag = null)Set a flag (turn the bit on)
long SetValue(long value, long valueFlag, int maxFlag = null)Sets a specified flag in the bitmask based on a numeric value Verifies that valueFlag is a valid bitmask flag and sets it
byte[] ToBytes(long input, Endianness endianness = null)Converts a long to a byte array considering endianness
long ToggleFlag(long value, int flag, int maxFlag = null)Toggle a flag (switch the bitmask state)
double ToGibiBytes(long l, int decimalPlaces = null)Converts bytes to gibibytes (1 GiB = 1,073,741,824 bytes).
double ToGigaBytes(long l, int decimalPlaces = null)Converts bytes to gigabytes (1 GB = 1,000,000,000 bytes).
double ToKibiBytes(long l, int decimalPlaces = null)Converts bytes to kibibytes (1 KiB = 1024 bytes).
double ToKiloBytes(long l, int decimalPlaces = null)Converts bytes to kilobytes (1 KB = 1000 bytes).
double ToMebiBytes(long l, int decimalPlaces = null)Converts bytes to mebibytes (1 MiB = 1,048,576 bytes).
double ToMegaBytes(long l, int decimalPlaces = null)Converts bytes to megabytes (1 MB = 1,000,000 bytes).
double ToPebiBytes(long l, int decimalPlaces = null)Converts bytes to pebibytes (1 PiB = 1,125,899,906,842,624 bytes).
double ToPetaBytes(long l, int decimalPlaces = null)Converts bytes to petabytes (1 PB = 1,000,000,000,000,000 bytes).
double ToTebiBytes(long l, int decimalPlaces = null)Converts bytes to tebibytes (1 TiB = 1,099,511,627,776 bytes).
double ToTeraBytes(long l, int decimalPlaces = null)Converts bytes to terabytes (1 TB = 1,000,000,000,000 bytes).
ByteSizeUnit Unit(long l)Returns the most appropriate unit for the value, based on thresholds.
string UnitSymbol(long l)Returns the most appropriate unit for the value, based on thresholds.
string UnitSymbolBinary(long l)Returns the most appropriate unit for the value, based on thresholds.
string UnitSymbolDecimal(long l)Returns the most appropriate unit for the value, based on thresholds.