You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: tests/pass/float.rs
+6-25
Original file line number
Diff line number
Diff line change
@@ -23,32 +23,12 @@ use std::{f32, f64};
23
23
/// First: The ULP of a float 'a' is the smallest possible change at 'a', so the ULP difference represents how
24
24
/// many discrete floating-point steps are needed to reach 'b' from 'a'.
25
25
///
26
-
/// There are 2 techniques we can use to compute the ULP difference of 2 floating-point numbers:
26
+
/// ULP(a) is the distance between the 2 closest floating-point numbers `x` and `y` around `a`, satisfying x < a < y, x != y.
27
+
/// To use this to calculate the ULP difference we have to halve it (we need it at `a`, but we just went "up" and "down", halving it gives us this ULP).
28
+
/// Then take the difference of `b` and `a` and divide it by that ULP and finally round it.
29
+
/// We know now how many floating-point changes we have to apply to `a` to get to `b`.
27
30
///
28
-
/// ULP(a) is the difference between 'a' and the next larger representable floating-point number.
29
-
/// So to get the ULP difference of `a` and `b`, we can take the absolute difference of
30
-
/// the *unsigned integer* representation of `a` and `b`.
31
-
/// For example checking 2 f32's, which in IEEE format looks like this:
0 commit comments