Class LongExtensions
- Namespace
- FishMMO.Shared
- Assembly
- FishMMO-SharedUtility.dll
Extension methods for 64-bit integers, providing deterministic absolute, clamping, digit counting, extraction, and scaling functionality.
public static class LongExtensions
- Inheritance
-
LongExtensions
- Inherited Members
Methods
Absolute(long)
public static long Absolute(this long number)
Parameters
numberlong
Returns
Clamp(long, long, long)
Clamps the long value to the specified inclusive minimum and maximum range.
public static long Clamp(this long number, long minimum, long maximum)
Parameters
Returns
DigitCount(long)
Returns the number of digits in the long value using a deterministic range check.
public static int DigitCount(this long number)
Parameters
numberlong
Returns
GetDigit(long, int)
Returns the specified digit of the long value. Zero is the least significant digit.
public static long GetDigit(this long number, int digitIndex)
Parameters
Returns
Normalize(long)
Normalizes the absolute value of a long to a double in the range [0, 1] by dividing by MaxValue.
Negative values are converted to their positive equivalent via
Absolute(long) before normalization. This means both
long.MaxValue and long.MinValue map to 1.0, and
a positive value and its negation map to the same result.
For signed normalization in [-1, 1], divide by long.MaxValue
directly without calling Absolute(long).
public static double Normalize(this long number)
Parameters
numberlong
Returns
ScaleToInt(long, int, int)
Scales a normalized value (assumed 0 to 1) to an integer in the specified range.
public static int ScaleToInt(this long number, int min = -2147483648, int max = 2147483647)