Table of Contents

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)

Returns the absolute value of the long number. Handles MinValue by returning MaxValue.

public static long Absolute(this long number)

Parameters

number long

Returns

long

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

number long
minimum long
maximum long

Returns

long

DigitCount(long)

Returns the number of digits in the long value using a deterministic range check.

public static int DigitCount(this long number)

Parameters

number long

Returns

int

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

number long
digitIndex int

Returns

long

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

number long

Returns

double

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)

Parameters

number long
min int
max int

Returns

int