Expand description
Integer ULP (unit in the last place) distance between floating point values.
Absolute and relative tolerances answer “is the result roughly right?”. ULP distance answers a sharper question: “how many representable floats apart are these two results?”. That is the useful metric when two implementations of the same kernel are supposed to be equivalent, because it stays meaningful across the whole dynamic range and cleanly separates a one-off rounding difference from a genuinely different computation.
The distance follows the usual total-ordering convention: adjacent floats are
1 apart, +0.0 and -0.0 are 1 apart (they are distinct representations),
two NaNs are 0 apart, and a NaN against anything else is UlpFloat::MAX_ULP.
Traits§
- UlpFloat
- Floating point types for which an integer ULP distance is defined.
Functions§
- max_
ulp_ distance - Largest ULP distance over two sequences, with the index where it occurs.
- ulp_
distance - Integer ULP distance between two floats of the same type.