Coverage Report

Created: 2026-01-10 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/libm-0.2.11/src/lib.rs
Line
Count
Source
1
//! libm in pure Rust
2
#![no_std]
3
#![cfg_attr(feature = "unstable", allow(internal_features))]
4
#![cfg_attr(feature = "unstable", feature(core_intrinsics))]
5
#![allow(clippy::assign_op_pattern)]
6
#![allow(clippy::deprecated_cfg_attr)]
7
#![allow(clippy::eq_op)]
8
#![allow(clippy::float_cmp)]
9
#![allow(clippy::int_plus_one)]
10
#![allow(clippy::many_single_char_names)]
11
#![allow(clippy::mixed_case_hex_literals)]
12
#![allow(clippy::needless_return)]
13
#![allow(clippy::unreadable_literal)]
14
15
mod libm_helper;
16
mod math;
17
18
use core::{f32, f64};
19
20
pub use libm_helper::*;
21
22
pub use self::math::*;
23
24
/// Approximate equality with 1 ULP of tolerance
25
#[doc(hidden)]
26
#[inline]
27
0
pub fn _eqf(a: f32, b: f32) -> Result<(), u32> {
28
0
    if a.is_nan() && b.is_nan() {
29
0
        Ok(())
30
    } else {
31
0
        let err = (a.to_bits() as i32).wrapping_sub(b.to_bits() as i32).abs();
32
33
0
        if err <= 1 { Ok(()) } else { Err(err as u32) }
34
    }
35
0
}
36
37
#[doc(hidden)]
38
#[inline]
39
0
pub fn _eq(a: f64, b: f64) -> Result<(), u64> {
40
0
    if a.is_nan() && b.is_nan() {
41
0
        Ok(())
42
    } else {
43
0
        let err = (a.to_bits() as i64).wrapping_sub(b.to_bits() as i64).abs();
44
45
0
        if err <= 1 { Ok(()) } else { Err(err as u64) }
46
    }
47
0
}