Table of Contents

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

number uint

The first value.

other uint

The value to subtract.

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

number uint

The value to clamp.

minimum uint

The lowest possible result.

maximum uint

The 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

number uint

The 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

number uint

The unsigned integer to extract from.

digitIndex int

The zero-based index of the digit.

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

number uint

The base value.

percent uint

The percentage to calculate (e.g., 20 for 20%).

Returns

uint

The rounded result.