Class ShortExtensions
- Namespace
- FishMMO.Shared
- Assembly
- FishMMO-SharedUtility.dll
Provides deterministic 16-bit signed integer (short) utility methods for the FishMMO framework. All calculations use pure integer math to ensure cross-platform consistency.
public static class ShortExtensions
- Inheritance
-
ShortExtensions
- Inherited Members
Methods
Absolute(short)
Returns the absolute value of the number. Handles MinValue (-32768) by returning MaxValue (32767) to prevent overflow.
public static short Absolute(this short number)
Parameters
numbershortThe signed short to process.
Returns
- short
The positive representation of the number.
Clamp(short, short, short)
Returns the number clamped to the specified inclusive minimum and maximum range.
public static short Clamp(this short number, short minimum, short maximum)
Parameters
Returns
- short
The clamped short value.
DigitCount(short)
Returns the total count of digits in the signed short using deterministic range checks.
public static int DigitCount(this short number)
Parameters
numbershortThe short to check.
Returns
- int
The number of digits (e.g., -1000 returns 4, 0 returns 1).
GetDigit(short, int)
Returns the specific digit at the given index, where 0 is the least significant digit (ones place).
public static short GetDigit(this short number, int digitIndex)
Parameters
Returns
- short
The single-digit value (0-9).
GetPercentOf(short, int)
Calculates a percentage of a signed short using integer math with standard rounding (0.5 rounds up).
public static short GetPercentOf(this short number, int percent)
Parameters
Returns
- short
The rounded result clamped to short boundaries.