Class UIntExtensions
- Namespace
- FishMMO.Shared
- Assembly
- FishMMO-SharedUtility.dll
Provides deterministic unsigned integer utility methods for the FishMMO framework. All calculations use pure integer math to ensure cross-platform consistency.
public static class UIntExtensions
- Inheritance
-
UIntExtensions
- Inherited Members
Methods
AbsoluteSubtract(uint, uint)
Returns the absolute difference between two unsigned values. Prevents underflow by checking which value is larger before subtraction.
public static uint AbsoluteSubtract(this uint number, uint other)
Parameters
Returns
- uint
The positive difference between the two values.
Clamp(uint, uint, uint)
Returns the value clamped to the specified inclusive minimum and maximum range.
public static uint Clamp(this uint number, uint minimum, uint maximum)
Parameters
numberuintThe value to clamp.
minimumuintThe lowest possible result.
maximumuintThe highest possible result.
Returns
- uint
The clamped unsigned integer value.
DigitCount(uint)
Returns the total count of digits in the current value using deterministic range checks.
public static int DigitCount(this uint number)
Parameters
numberuintThe unsigned integer to check.
Returns
- int
The number of digits (e.g., 100 returns 3, 0 returns 1).
GetDigit(uint, int)
Returns the specific digit at the given index, where 0 is the least significant digit (ones place).
public static uint GetDigit(this uint number, int digitIndex)
Parameters
Returns
- uint
The single-digit value (0-9).
GetPercentOf(uint, uint)
Calculates a percentage of a value using integer math with standard rounding (0.5 rounds up). Formula: (number * percent + 50) / 100
public static uint GetPercentOf(this uint number, uint percent)
Parameters
Returns
- uint
The rounded result.