Coverage Report

Created: 2024-09-10 12:50

/build/cargo-vendor-dir/libm-0.2.8/src/math/nextafter.rs
Line
Count
Source (jump to first uncovered line)
1
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
2
0
pub fn nextafter(x: f64, y: f64) -> f64 {
3
0
    if x.is_nan() || y.is_nan() {
4
0
        return x + y;
5
0
    }
6
0
7
0
    let mut ux_i = x.to_bits();
8
0
    let uy_i = y.to_bits();
9
0
    if ux_i == uy_i {
10
0
        return y;
11
0
    }
12
0
13
0
    let ax = ux_i & !1_u64 / 2;
14
0
    let ay = uy_i & !1_u64 / 2;
15
0
    if ax == 0 {
16
0
        if ay == 0 {
17
0
            return y;
18
0
        }
19
0
        ux_i = (uy_i & 1_u64 << 63) | 1;
20
0
    } else if ax > ay || ((ux_i ^ uy_i) & 1_u64 << 63) != 0 {
21
0
        ux_i -= 1;
22
0
    } else {
23
0
        ux_i += 1;
24
0
    }
25
26
0
    let e = ux_i.wrapping_shr(52 & 0x7ff);
27
0
    // raise overflow if ux.f is infinite and x is finite
28
0
    if e == 0x7ff {
29
0
        force_eval!(x + x);
30
0
    }
31
0
    let ux_f = f64::from_bits(ux_i);
32
0
    // raise underflow if ux.f is subnormal or zero
33
0
    if e == 0 {
34
0
        force_eval!(x * x + ux_f * ux_f);
35
0
    }
36
0
    ux_f
37
0
}