Table of Contents

Class FloatExtensions

Namespace
FishMMO.Shared
Assembly
FishMMO-SharedUtility.dll

Extension methods for float values, providing absolute, clamping, min/max, and digit counting functionality.

public static class FloatExtensions
Inheritance
FloatExtensions
Inherited Members

Methods

Absolute(float)

Returns the absolute value of the float number.

public static float Absolute(this float number)

Parameters

number float

Returns

float

Clamp(float, float, float)

Clamps the float value to the specified inclusive minimum and maximum range.

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

Parameters

number float
minimum float
maximum float

Returns

float

Remarks

NaN behavior: IEEE 754 comparisons involving NaN always return false, so NaN passes through this clamp unmodified. If NaN should be replaced with minimum, call float.IsNaN() before clamping.

DigitCount(float)

Returns the number of digits in the integer part of the float value. Note: Accuracy is limited by the 7-digit precision of the float type.

public static int DigitCount(this float number)

Parameters

number float

Returns

int

IsNearlyEqual(float, float, float)

Determines if two floats are effectively equal within a specific tolerance (Epsilon). Standard for comparing physics or movement values in networked environments.

public static bool IsNearlyEqual(this float a, float b, float epsilon = 0.0001)

Parameters

a float
b float
epsilon float

Returns

bool

Max(float, float)

Returns the larger of two single-precision floating-point numbers.

public static float Max(this float number, float other)

Parameters

number float
other float

Returns

float

Min(float, float)

Returns the smaller of two single-precision floating-point numbers.

public static float Min(this float number, float other)

Parameters

number float
other float

Returns

float