Class DoubleExtensions
- Namespace
- FishMMO.Shared
- Assembly
- FishMMO-SharedUtility.dll
Extension methods for double-precision floating-point numbers.
public static class DoubleExtensions
- Inheritance
-
DoubleExtensions
- Inherited Members
Methods
Absolute(double)
Returns the absolute value of the number.
public static double Absolute(this double number)
Parameters
numberdoubleThe value to process.
Returns
- double
The positive representation of the number.
Clamp(double, double, double)
Returns the number clamped to the specified inclusive minimum and maximum range.
public static double Clamp(this double number, double minimum, double maximum)
Parameters
Returns
- double
The clamped value.
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
double.IsNaN() before clamping.
DigitCount(double)
Returns the number of digits in the integer portion of the value. Note: For values larger than 10^15, precision limits of double may affect accuracy.
public static int DigitCount(this double number)
Parameters
numberdoubleThe value to check.
Returns
- int
The count of digits before the decimal point.
IsNearlyEqual(double, double, double)
Determines if two doubles are effectively equal within a specific tolerance. Crucial for avoiding precision errors in networked game logic.
public static bool IsNearlyEqual(this double a, double b, double epsilon = 1E-06)