Shared Rust kernels

ported/excel_numeric/soft87

All modules · quoted at commit 9e1884369a67 of DnaCalc/DnaCalc. Comments are the source's own.

pack_raw · 7 lines · calc-func/src/ported/excel_numeric/soft87.rs on GitHub
fn pack_raw(neg: bool, biased: u16, sig: u64) -> Ext80 {
    let mut out = [0u8; 10];
    out[..8].copy_from_slice(&sig.to_le_bytes());
    let se = biased | if neg { 0x8000 } else { 0 };
    out[8..].copy_from_slice(&se.to_le_bytes());
    Ext80(out)
}

Used by 17 functions.

zero · 3 lines · calc-func/src/ported/excel_numeric/soft87.rs on GitHub
fn zero(neg: bool) -> Ext80 {
    pack_raw(neg, 0, 0)
}

Used by 17 functions.

inf · 3 lines · calc-func/src/ported/excel_numeric/soft87.rs on GitHub
fn inf(neg: bool) -> Ext80 {
    pack_raw(neg, 0x7fff, 0x8000_0000_0000_0000)
}

Used by 17 functions.

pack · 12 lines · calc-func/src/ported/excel_numeric/soft87.rs on GitHub
/// Packs a finite value `sig * 2^(exp - 63)` (top bit of `sig` set), already rounded.
fn pack(neg: bool, exp: i32, sig: u64) -> Ext80 {
    let biased = exp + BIAS;
    if biased >= 0x7fff {
        return inf(neg);
    }
    if biased <= 0 {
        // Below the normal extended range: no chain reaches it (see the module docs).
        return zero(neg);
    }
    pack_raw(neg, biased as u16, sig)
}

Used by 17 functions.

ext_pi · 4 lines · calc-func/src/ported/excel_numeric/soft87.rs on GitHub
/// `FLDPI`: pi rounded to the 64-bit significand.
pub(crate) fn ext_pi() -> Ext80 {
    pack(false, 1, 0xC90F_DAA2_2168_C235)
}

Used by 16 functions.

ext_one · 4 lines · calc-func/src/ported/excel_numeric/soft87.rs on GitHub
/// `FLD1`.
pub(crate) fn ext_one() -> Ext80 {
    pack(false, 0, 0x8000_0000_0000_0000)
}

Used by 15 functions.

ext_abs · 6 lines · calc-func/src/ported/excel_numeric/soft87.rs on GitHub
/// `FABS`.
pub(crate) fn ext_abs(x: &Ext80, _cw: u16) -> Ext80 {
    let mut out = *x;
    out.0[9] &= 0x7f;
    out
}

Used by 4 functions.

ext_chs · 6 lines · calc-func/src/ported/excel_numeric/soft87.rs on GitHub
/// `FCHS`.
pub(crate) fn ext_chs(x: &Ext80, _cw: u16) -> Ext80 {
    let mut out = *x;
    out.0[9] ^= 0x80;
    out
}

Used by 12 functions.