Table of Contents

Class ByteExtensions

Namespace
FishMMO.Shared
Assembly
FishMMO-SharedUtility.dll

Provides deterministic byte utility methods for the FishMMO framework. All calculations use pure integer math to ensure cross-platform consistency.

public static class ByteExtensions
Inheritance
ByteExtensions
Inherited Members

Methods

Clamp(byte, byte, byte)

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

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

Parameters

number byte

The value to clamp.

minimum byte

The lowest possible result.

maximum byte

The highest possible result.

Returns

byte

The clamped byte value.

DigitCount(byte)

Returns the total count of digits in the byte value using deterministic range checks.

public static int DigitCount(this byte number)

Parameters

number byte

The byte to check (0-255).

Returns

int

The number of digits (e.g., 255 returns 3, 0 returns 1).

GetDigit(byte, int)

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

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

Parameters

number byte

The byte to extract from.

digitIndex int

The zero-based index of the digit.

Returns

byte

The single-digit value (0-9).

GetPercentOf(byte, int)

Calculates a percentage of a byte using integer math with standard rounding (0.5 rounds up). Useful for small-value modifiers like status effects.

public static byte GetPercentOf(this byte number, int percent)

Parameters

number byte

The base value.

percent int

The percentage to calculate (0-100+).

Returns

byte

The rounded result clamped back to a byte.