Table of Contents

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

number short

The 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

number short

The value to clamp.

minimum short

The lower bound.

maximum short

The upper bound.

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

number short

The 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

number short

The signed short to extract from.

digitIndex int

The zero-based index of the digit.

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

number short

The base value.

percent int

The percentage to calculate (e.g. 10 for 10%).

Returns

short

The rounded result clamped to short boundaries.