Table of Contents

Class SByteExtensions

Namespace
FishMMO.Shared
Assembly
FishMMO-SharedUtility.dll

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

public static class SByteExtensions
Inheritance
SByteExtensions
Inherited Members

Methods

Absolute(sbyte)

Returns the absolute value of the number. Handles MinValue (-128) by returning MaxValue (127) to prevent overflow.

public static sbyte Absolute(this sbyte number)

Parameters

number sbyte

The signed byte to process.

Returns

sbyte

The positive representation of the number.

Clamp(sbyte, sbyte, sbyte)

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

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

Parameters

number sbyte

The value to clamp.

minimum sbyte

The lowest possible result.

maximum sbyte

The highest possible result.

Returns

sbyte

The clamped signed byte value.

DigitCount(sbyte)

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

public static int DigitCount(this sbyte number)

Parameters

number sbyte

The signed byte to check.

Returns

int

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

GetDigit(sbyte, int)

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

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

Parameters

number sbyte

The signed byte to extract from.

digitIndex int

The zero-based index of the digit.

Returns

sbyte

The single-digit value (0-9).

GetPercentOf(sbyte, int)

Calculates a percentage of a signed byte using integer math with standard rounding (0.5 rounds up). Formula: (number * percent + 50) / 100

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

Parameters

number sbyte

The base value.

percent int

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

Returns

sbyte

The rounded result clamped to sbyte boundaries.