Class IntExtensions
- Namespace
- FishMMO.Shared
- Assembly
- FishMMO-SharedUtility.dll
Provides deterministic integer utility methods for the FishMMO framework. All calculations use pure integer math to ensure cross-platform consistency.
public static class IntExtensions
- Inheritance
-
IntExtensions
- Inherited Members
Methods
Absolute(int)
public static int Absolute(this int number)
Parameters
numberintThe integer to process.
Returns
- int
The positive representation of the number.
Clamp(int, int, int)
Returns the number clamped to the specified inclusive minimum and maximum range.
public static int Clamp(this int number, int minimum, int maximum)
Parameters
numberintThe value to clamp.
minimumintThe lowest possible result.
maximumintThe highest possible result.
Returns
- int
The clamped integer value.
DigitCount(int)
Returns the total count of digits in the current value.
public static int DigitCount(this int number)
Parameters
numberintThe integer to check.
Returns
- int
The number of digits (e.g., -100 returns 3, 0 returns 1).
GetDigit(int, int)
Returns the specific digit at the given index, where 0 is the least significant digit (ones place).
public static int GetDigit(this int number, int digitIndex)
Parameters
Returns
- int
The single-digit integer (0-9).
GetPercentOf(int, int)
Calculates a percentage of a number using integer math with standard rounding (0.5 rounds up). Formula: (number * percent + 50) / 100
public static int GetPercentOf(this int number, int percent)
Parameters
Returns
- int
The rounded result.
SubtractPercent(int, int)
Subtracts a percentage from the number using deterministic integer math. Useful for calculating discounted prices or damage reduction.
public static int SubtractPercent(this int number, int percent)
Parameters
Returns
- int
The rounded result after subtraction.