softfpu 0.3.0

32-, 64- and 80-bit floating-point arithmetic in safe Rust, including Intel x87 transcendental functions
Documentation
//! x86 floating-point arithmetic.
//!
//! [`Real`] implements SSE lane arithmetic on binary32 and binary64.
//! [`extended`] implements x87 arithmetic on canonical 80-bit operands.
//! The caller handles the x87 stack, exception masks, denormal-operand
//! detection, SSE denormals-are-zero on inputs, SSE flush to zero on results
//! and destination writes.
//!
//! # NaNs and invalid conversions
//!
//! [`X86`] quiets a NaN by setting fraction bit 22 for binary32, fraction
//! bit 51 for binary64, or significand bit 62 for extended. A signalling
//! operand raises [`Flags::INVALID`], except in [`reciprocal()`] and
//! [`reciprocal_sqrt`], which quiet the NaN and raise nothing. Binary32 and binary64 choose the first
//! NaN in operand order. When both extended operands are NaNs, a quiet NaN
//! wins over a signalling NaN. Otherwise the larger significand wins, with
//! positive preferred on a tie. The selected NaN keeps its sign.
//!
//! An invalid operation without a NaN operand gives the negative quiet NaN
//! with a zero payload. Across formats a NaN keeps its sign and its leading
//! payload bits. Widening fills the low payload bits with zeros. A failed
//! signed-integer conversion returns the destination's most negative value
//! with invalid alone.
//!
//! # Flags and range responses
//!
//! Operations report [`Flags`]. The denormal-operand exception belongs to the
//! instruction caller, which applies its operand rules.
//!
//! Masked rounding uses tininess after rounding. For an unmasked x87 register
//! overflow or underflow, [`extended::round_unmasked`] rounds the original
//! intermediate with an unbounded exponent, then adjusts that exponent.
//! For SSE, [`Real::unmasked_flags`] reports the flags for an unmasked
//! range response. The instruction suppresses the destination write.

pub mod double;
pub mod extended;
pub mod reciprocal;
pub mod transcendental;

mod policy;
mod real;

#[cfg(test)]
mod tests;

pub use crate::{
    Category, Computed, Double, Extended, Flags, Precision, Relation, Rounded, Rounding, Single,
    Unrounded,
};
pub use policy::X86;
pub use real::Real;
pub use reciprocal::{reciprocal, reciprocal_sqrt};

// Returns the x86 result of a conversion to an integer. A failed conversion
// gives the integer indefinite, which is the destination's most negative
// value, with invalid alone.
fn indefinite<T>(
    converted: Result<Rounded<T>, crate::InvalidConversion>,
    indefinite: T,
) -> Rounded<T> {
    match converted {
        Ok(rounded) => rounded,
        Err(_) => Rounded::exact(indefinite, Flags::INVALID),
    }
}