Table of Contents

Class UShortExtensions

Namespace
FishMMO.Shared
Assembly
FishMMO-SharedUtility.dll

Provides deterministic 16-bit unsigned integer (ushort) utility methods for the FishMMO framework. All calculations use pure integer math to ensure cross-platform consistency.

public static class UShortExtensions
Inheritance
UShortExtensions
Inherited Members

Methods

AbsoluteSubtract(ushort, ushort)

Returns the absolute difference between two unsigned 16-bit values. Prevents underflow by checking which value is larger before subtraction.

public static ushort AbsoluteSubtract(this ushort number, ushort other)

Parameters

number ushort
other ushort

Returns

ushort

Clamp(ushort, ushort, ushort)

Returns the value clamped to the specified inclusive minimum and maximum range.

public static ushort Clamp(this ushort number, ushort minimum, ushort maximum)

Parameters

number ushort
minimum ushort
maximum ushort

Returns

ushort

DigitCount(ushort)

Returns the total count of digits in the unsigned short using deterministic range checks.

public static int DigitCount(this ushort number)

Parameters

number ushort

The ushort to check (0-65535).

Returns

int

The number of digits (e.g., 65535 returns 5, 0 returns 1).

GetDigit(ushort, int)

Returns the specific digit at the given index, where 0 is the least significant digit (ones place).

public static ushort GetDigit(this ushort number, int digitIndex)

Parameters

number ushort

The unsigned short to extract from.

digitIndex int

The zero-based index of the digit.

Returns

ushort

The single-digit value (0-9).

GetPercentOf(ushort, ushort)

Calculates a percentage of an unsigned short using integer math with rounding. Formula: (number * percent + 50) / 100

public static ushort GetPercentOf(this ushort number, ushort percent)

Parameters

number ushort
percent ushort

Returns

ushort