(x: f64)
| 189 | } |
| 190 | |
| 191 | pub fn ulp(x: f64) -> f64 { |
| 192 | if x.is_nan() { |
| 193 | return x; |
| 194 | } |
| 195 | let x = x.abs(); |
| 196 | let x2 = nextafter(x, f64::INFINITY); |
| 197 | if x2.is_infinite() { |
| 198 | // special case: x is the largest positive representable float |
| 199 | let x2 = nextafter(x, f64::NEG_INFINITY); |
| 200 | x - x2 |
| 201 | } else { |
| 202 | x2 - x |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | pub fn round_float_digits(x: f64, ndigits: i32) -> Option<f64> { |
| 207 | let float = if ndigits.is_zero() { |
nothing calls this directly
no test coverage detected