Sha256: 4f198d06db1896386256fb9a5ac5b805b16b836226c18780a475cf18d7c1449c

Contents?: true

Size: 807 Bytes

Versions: 11

Compression:

Stored size: 807 Bytes

Contents

#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub fn scalbnf(mut x: f32, mut n: i32) -> f32 {
    let x1p127 = f32::from_bits(0x7f000000); // 0x1p127f === 2 ^ 127
    let x1p_126 = f32::from_bits(0x800000); // 0x1p-126f === 2 ^ -126
    let x1p24 = f32::from_bits(0x4b800000); // 0x1p24f === 2 ^ 24

    if n > 127 {
        x *= x1p127;
        n -= 127;
        if n > 127 {
            x *= x1p127;
            n -= 127;
            if n > 127 {
                n = 127;
            }
        }
    } else if n < -126 {
        x *= x1p_126 * x1p24;
        n += 126 - 24;
        if n < -126 {
            x *= x1p_126 * x1p24;
            n += 126 - 24;
            if n < -126 {
                n = -126;
            }
        }
    }
    x * f32::from_bits(((0x7f + n) as u32) << 23)
}

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/scalbnf.rs
wasmtime-28.0.0 ./ext/cargo-vendor/libm-0.2.11/src/math/scalbnf.rs
wasmtime-27.0.0 ./ext/cargo-vendor/libm-0.2.11/src/math/scalbnf.rs
wasmtime-26.0.0 ./ext/cargo-vendor/libm-0.2.8/src/math/scalbnf.rs
wasmtime-25.0.2 ./ext/cargo-vendor/libm-0.2.8/src/math/scalbnf.rs
wasmtime-25.0.1 ./ext/cargo-vendor/libm-0.2.8/src/math/scalbnf.rs
wasmtime-25.0.0 ./ext/cargo-vendor/libm-0.2.8/src/math/scalbnf.rs
wasmtime-24.0.0 ./ext/cargo-vendor/libm-0.2.8/src/math/scalbnf.rs
wasmtime-23.0.2 ./ext/cargo-vendor/libm-0.2.8/src/math/scalbnf.rs
wasmtime-22.0.0 ./ext/cargo-vendor/libm-0.2.8/src/math/scalbnf.rs
wasmtime-21.0.1 ./ext/cargo-vendor/libm-0.2.8/src/math/scalbnf.rs