the number of mantissa bits which are equal in x and y. eg, 0x1.F8p+60 and 0x1.F1p+60 are equal to 5 bits of precision.
x | y | feqrel(x, y) |
---|---|---|
x | x | real.mant_dig |
x | >= 2*x | 0 |
x | <= x/2 | 0 |
NaN | any | 0 |
any | NaN | 0 |
assert(feqrel(2.0, 2.0) == 53); assert(feqrel(2.0f, 2.0f) == 24); assert(feqrel(2.0, double.nan) == 0); // Test that numbers are within n digits of each // other by testing if feqrel > n * log2(10) // five digits assert(feqrel(2.0, 2.00001) > 16); // ten digits assert(feqrel(2.0, 2.00000000001) > 33);
To what precision is x equal to y?