(x: f32)
| 282 | // Next representable f32 strictly less than `x`. |
| 283 | #[inline] |
| 284 | fn next_down_f32(x: f32) -> f32 { |
| 285 | if x.is_nan() || x == f32::NEG_INFINITY { |
| 286 | return x; |
| 287 | } |
| 288 | let bits = x.to_bits(); |
| 289 | if x.is_sign_negative() { |
| 290 | // negative: increasing magnitude moves toward -inf |
| 291 | f32::from_bits(bits + 1) |
| 292 | } else { |
| 293 | // positive or +0: decreasing bits moves toward 0 and then negative |
| 294 | if bits == 0 { |
| 295 | f32::from_bits(0x8000_0001) // +0 -> smallest negative subnormal |
| 296 | } else { |
| 297 | f32::from_bits(bits - 1) |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | // --- f64 -> f32 with explicit rounding mode --- |
| 303 | // Round with the host default (RNE), then nudge one ULP when the result lands on |
no outgoing calls
no test coverage detected