Method AreCloseBitwiseEx
AreCloseBitwiseEx(double, double, int)
Determines whether two double values are equal within a specified number of representable steps. This comparison is based on the binary distance between the two values in IEEE 754 format, making it suitable for bitwise proximity checks, serialization validation, and low-level diagnostics.
public static bool AreCloseBitwiseEx(double a, double b, int maxSteps = 4)
Parameters
adoubleThe first double value to compare.
bdoubleThe second double value to compare.
maxStepsintThe maximum number of representable floating-point steps (units in the last place) allowed between
aandb. A value of 4 allows for minor rounding differences while still ensuring tight binary proximity. Increase this value to tolerate more drift; decrease it for stricter equivalence.
Returns
- bool
trueif the binary representations ofaandbdiffer by no more thanmaxStepssteps; otherwise,false.
- See Also