Table of Contents

Method AreCloseBitwise

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

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

a double

The first double-precision floating-point number to compare.

b double

The second double-precision floating-point number to compare.

Returns

bool

true if the bitwise difference between a and b is within a small threshold; otherwise, false.

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

a float

First value to compare.

b float

Second value to compare.

Returns

bool

true if 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.