Method AreCloseBitwise
AreCloseBitwise(double, double)
Determines whether two double-precision floating-point numbers are equal within a small bitwise difference.
public static bool AreCloseBitwise(double a, double b)
Parameters
adoubleThe first double-precision floating-point number to compare.
bdoubleThe second double-precision floating-point number to compare.
Returns
Remarks
This method compares the bitwise representations of the two numbers and allows for a maximum difference of 4 in their bitwise values. It accounts for sign differences explicitly and falls back to a direct comparison when the signs differ.
- See Also
AreCloseBitwise(float, float)
Returns true if the two single-precision floats are close enough to be considered equal, based on bitwise proximity. Handles sign differences explicitly.
public static bool AreCloseBitwise(float a, float b)
Parameters
Returns
- bool
trueif the values are within a few representable steps; otherwise,false.
Examples
AreCloseBitwise(1.0f, 1.0000001f) // true
AreCloseBitwise(0.0f, -0.0f) // true
AreCloseBitwise(float.NaN, float.NaN) // false
AreCloseBitwise(float.PositiveInfinity, float.PositiveInfinity) // true
Remarks
This method compares the bitwise distance between two floats, allowing up
to maxSteps ULPs (Units in the Last Place).
It is symmetric with AreCloseBitwise(double, double)
and suitable for low-level numeric diagnostics.