Coverage Report

Created: 2025-11-16 07:04

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