Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libm-test/src/f8_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ impl Float for f8 {
libm::generic::copysign(self, other)
}

fn roundeven(self) -> Self {
libm::generic::rint_status(self).val
}

fn fma(self, _y: Self, _z: Self) -> Self {
unimplemented!()
}
Expand Down
3 changes: 2 additions & 1 deletion libm-test/src/precision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ pub fn default_ulp(ctx: &CheckCtx) -> Option<u32> {
Bn::Erf => 1,
Bn::Erfc => 4,
Bn::Exp => 1,
Bn::Exp10 => 6,
Bn::Exp10 if ctx.fn_ident == Id::Exp10f => 6,
Bn::Exp10 => 0,
Bn::Exp2 => 1,
Bn::Expm1 => 1,
Bn::Hypot => 1,
Expand Down
23 changes: 23 additions & 0 deletions libm/src/math/approx/exp10f64.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use super::super::{exp2, modf, pow};

const LN10: f64 = 3.32192809488736234787031942948939;
const P10: &[f64] = &[
1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1,
1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
];

/// Calculates 10 raised to the power of `x` (f64).
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
pub fn exp10f64(x: f64) -> f64 {
let (mut y, n) = modf(x);
let u: u64 = n.to_bits();
/* fabs(n) < 16 without raising invalid on nan */
if ((u >> 52) & 0x7ff) < 0x3ff + 4 {
if y == 0.0 {
return i!(P10, ((n as isize) + 15) as usize);
}
y = exp2(LN10 * y);
return y * i!(P10, ((n as isize) + 15) as usize);
}
return pow(10.0, x);
}
2 changes: 2 additions & 0 deletions libm/src/math/approx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
//! not be as accurate.

mod cbrtf64;
mod exp10f64;

pub use cbrtf64::cbrtf64;
pub use exp10f64::exp10f64;
Loading
Loading