Coverage Report

Created: 2026-05-30 06:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/libm-0.2.16/src/math/hypotf.rs
Line
Count
Source
1
use super::sqrtf;
2
3
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
4
0
pub fn hypotf(mut x: f32, mut y: f32) -> f32 {
5
0
    let x1p90 = f32::from_bits(0x6c800000); // 0x1p90f === 2 ^ 90
6
0
    let x1p_90 = f32::from_bits(0x12800000); // 0x1p-90f === 2 ^ -90
7
8
0
    let mut uxi = x.to_bits();
9
0
    let mut uyi = y.to_bits();
10
    let uti;
11
    let mut z: f32;
12
13
0
    uxi &= -1i32 as u32 >> 1;
14
0
    uyi &= -1i32 as u32 >> 1;
15
0
    if uxi < uyi {
16
0
        uti = uxi;
17
0
        uxi = uyi;
18
0
        uyi = uti;
19
0
    }
20
21
0
    x = f32::from_bits(uxi);
22
0
    y = f32::from_bits(uyi);
23
0
    if uyi == 0xff << 23 {
24
0
        return y;
25
0
    }
26
0
    if uxi >= 0xff << 23 || uyi == 0 || uxi - uyi >= 25 << 23 {
27
0
        return x + y;
28
0
    }
29
30
0
    z = 1.;
31
0
    if uxi >= (0x7f + 60) << 23 {
32
0
        z = x1p90;
33
0
        x *= x1p_90;
34
0
        y *= x1p_90;
35
0
    } else if uyi < (0x7f - 60) << 23 {
36
0
        z = x1p_90;
37
0
        x *= x1p90;
38
0
        y *= x1p90;
39
0
    }
40
0
    z * sqrtf((x as f64 * x as f64 + y as f64 * y as f64) as f32)
41
0
}