Table of Contents

Method AreCloseBitwiseEx

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

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

a double

The first double value to compare.

b double

The second double value to compare.

maxSteps int

The maximum number of representable floating-point steps (units in the last place) allowed between a and b. 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

true if the binary representations of a and b differ by no more than maxSteps steps; otherwise, false.

See Also