Sha256: 2e136c6ecedd8e57a6c31796f57fae4546fcfd8bc6be66c836f553df9c74b907

Contents?: true

Size: 754 Bytes

Versions: 11

Compression:

Stored size: 754 Bytes

Contents

use 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,
];

#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub fn exp10(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);
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/libm-0.2.11/src/math/exp10.rs
wasmtime-28.0.0 ./ext/cargo-vendor/libm-0.2.11/src/math/exp10.rs
wasmtime-27.0.0 ./ext/cargo-vendor/libm-0.2.11/src/math/exp10.rs
wasmtime-26.0.0 ./ext/cargo-vendor/libm-0.2.8/src/math/exp10.rs
wasmtime-25.0.2 ./ext/cargo-vendor/libm-0.2.8/src/math/exp10.rs
wasmtime-25.0.1 ./ext/cargo-vendor/libm-0.2.8/src/math/exp10.rs
wasmtime-25.0.0 ./ext/cargo-vendor/libm-0.2.8/src/math/exp10.rs
wasmtime-24.0.0 ./ext/cargo-vendor/libm-0.2.8/src/math/exp10.rs
wasmtime-23.0.2 ./ext/cargo-vendor/libm-0.2.8/src/math/exp10.rs
wasmtime-22.0.0 ./ext/cargo-vendor/libm-0.2.8/src/math/exp10.rs
wasmtime-21.0.1 ./ext/cargo-vendor/libm-0.2.8/src/math/exp10.rs