Table of Contents

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)

Returns the absolute value of the number. Handles MinValue by returning MaxValue.

public static int Absolute(this int number)

Parameters

number int

The 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

number int

The value to clamp.

minimum int

The lowest possible result.

maximum int

The 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

number int

The 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

number int

The integer to extract from.

digitIndex int

The zero-based index of the digit.

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

number int

The base value.

percent int

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

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

number int

The starting value.

percent int

The percentage to subtract.

Returns

int

The rounded result after subtraction.