Sign in

    softfloat

    Software floating-point arithmetic with explicit rounding and exception state.

    Download zip
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    2 hours ago
    Downloads
    1

    No dependencies

    #MoonBit SoftFloat

    This repository is a pure MoonBit implementation of Soft Float.

    The implementation keeps SoftFloat state explicit: operations thread a Context value that carries rounding mode, tininess mode, exception flags, and the selected specialization profile.

    BF16

    pub struct BF16(UInt16)

    IEEE 754 bfloat16 bit wrapper used by SoftFloat conversion operations.

    The stored value is the raw 16-bit payload. v1 includes BF16 conversion and NaN classification, but no standalone BF16 arithmetic. All BF16 bit patterns are representable by this wrapper.

    BF16::from_bits

    fn BF16::from_bits(bits : UInt16) -> BF16

    Creates a BF16 from its raw bfloat16 bits.

    Construction is purely bit-level: NaNs, infinities, subnormals, and signed zeros are preserved without raising flags.

    BF16::is_signaling_nan

    fn BF16::is_signaling_nan(self : BF16) -> Bool

    Returns true when this BF16 bit pattern is a signaling NaN.

    This helper only inspects the raw exponent and fraction bits. It never raises flags, so callers that need SoftFloat invalid-flag behavior should use a conversion or arithmetic operation instead.

    BF16::to_bits

    fn BF16::to_bits(self : BF16) -> UInt16

    Returns the raw bfloat16 bits stored in this value.

    This is an exact round trip for every value created by BF16::from_bits.

    BF16::to_f32

    fn BF16::to_f32(self : BF16, context : Context) -> SoftResult[F32]

    Converts BF16 to F32 with SoftFloat NaN handling.

    Finite values, including signed zeros and subnormals, are widened exactly by padding the BF16 fraction with 16 zero bits. Infinities keep their sign. NaNs use the selected specialization's common-NaN conversion; signaling NaNs raise Invalid, while quiet NaNs do not.

    Context

    pub(all) struct Context {
    rounding : RoundingMode
    tininess : TininessMode
    flags : ExceptionFlags
    specialization : Specialization
    }

    Explicit SoftFloat execution context.

    The context replaces SoftFloat's global mutable rounding mode, tininess mode, exception flags, and specialization profile. Public operations return a SoftResult with an updated context; the input context value is not mutated. Existing flags are preserved until Context::clear_flags is used.

    Context::clear_flags

    fn Context::clear_flags(self : Context) -> Context

    Returns this context with all accumulated exception flags cleared.

    Rounding mode, tininess mode, and specialization are preserved.

    Context::default

    fn Context::default() -> Context

    Returns the default v1 context.

    The defaults are round-near-even, tininess-after-rounding, no exception flags, and the X86_8086SSE specialization. Boundary cases therefore use the 8086-SSE default NaNs and invalid integer results unless the specialization is changed explicitly.

    Context::raise_flags

    fn Context::raise_flags(self : Context, flags : ExceptionFlags) -> Context

    Returns this context with flags accumulated.

    MoonBit reserves raise as a keyword, so this method is named raise_flags while preserving the explicit-flag accumulation semantics specified by SoftFloat. Passing an empty flag set is a no-op; passing multiple bits raises all of them at once.

    Context::riscv

    fn Context::riscv() -> Context

    Returns the default RISCV specialization context.

    Rounding, tininess, and flags match Context::default; only the specialization changes. This affects default NaNs, NaN propagation details, and invalid integer result constants for later operations.

    Context::with_rounding

    fn Context::with_rounding(self : Context, rounding : RoundingMode) -> Context

    Returns this context with a different rounding mode and unchanged flags.

    Accumulated flags are intentionally preserved; call clear_flags first if the new rounding mode should start a fresh operation log.

    Context::with_specialization

    fn Context::with_specialization(self : Context, specialization : Specialization) -> Context

    Returns this context with a different specialization and unchanged flags.

    The new specialization only affects future operations. Already accumulated flags remain as-is.

    Context::with_tininess

    fn Context::with_tininess(self : Context, tininess : TininessMode) -> Context

    Returns this context with a different tininess mode and unchanged flags.

    The mode only affects future underflow flag decisions.

    ExceptionFlags

    pub struct ExceptionFlags(UInt)

    Accumulated IEEE exception flags.

    Bits match SoftFloat: Inexact=1, Underflow=2, Overflow=4, Infinite=8, Invalid=16. Flags are immutable and accumulated through Context::raise_flags; operations preserve any flags already present in the input context and OR in newly raised flags. Use from_bits when importing raw flag bits; it masks off bits outside the SoftFloat range.

    ExceptionFlags::contains

    fn ExceptionFlags::contains(self : ExceptionFlags, flag : ExceptionFlags) -> Bool

    Returns true when all bits in flag are present in this flag set.

    Passing ExceptionFlags::empty() returns true. Passing a multi-bit flag set only returns true when every requested bit is present.

    ExceptionFlags::empty

    Returns an empty exception-flag set.

    This value has raw bits 0 and is contained by every flag set when passed to ExceptionFlags::contains.

    ExceptionFlags::from_bits

    fn ExceptionFlags::from_bits(bits : UInt) -> ExceptionFlags

    Creates exception flags from raw SoftFloat flag bits.

    Bits outside the SoftFloat exception mask are discarded, so ExceptionFlags::from_bits(bits).to_bits() is always in 0x00..0x1f.

    ExceptionFlags::inexact

    SoftFloat inexact flag.

    Raised when a finite result had to be rounded or when an exact-conversion request loses nonzero bits.

    ExceptionFlags::infinite

    fn ExceptionFlags::infinite() -> ExceptionFlags

    SoftFloat infinite flag.

    Raised for finite nonzero division by zero, producing a signed infinity.

    ExceptionFlags::invalid

    SoftFloat invalid flag.

    Raised for operations such as signaling-NaN consumption, invalid infinity arithmetic, square root of a negative nonzero value, and invalid float-to-integer conversions.

    ExceptionFlags::merge

    Returns a flag set with other accumulated.

    This is a bitwise OR operation. It never clears existing flags and merging the same flag repeatedly is idempotent.

    ExceptionFlags::overflow

    fn ExceptionFlags::overflow() -> ExceptionFlags

    SoftFloat overflow flag.

    Raised when a finite floating result is too large for the destination format. Overflow is paired with Inexact by the rounding helpers.

    ExceptionFlags::to_bits

    fn ExceptionFlags::to_bits(self : ExceptionFlags) -> UInt

    Returns the raw SoftFloat exception flag bits.

    Only the low five bits are used by this package.

    ExceptionFlags::underflow

    fn ExceptionFlags::underflow() -> ExceptionFlags

    SoftFloat underflow flag.

    Raised for tiny inexact floating results according to the context's tininess mode.

    F16

    pub struct F16(UInt16)

    IEEE 754 binary16 bit wrapper used by SoftFloat operations.

    The stored value is the raw 16-bit payload. Public construction is through F16::from_bits; operations never reinterpret it through host floats. All bit patterns are accepted, including signed zeros, subnormals, infinities, quiet NaNs, and signaling NaNs.

    F16::add

    fn F16::add(self : F16, context : Context, rhs : F16) -> SoftResult[F16]

    Adds two F16 values using the rounding mode carried by context.

    NaNs are propagated, with signaling NaNs raising Invalid. Adding opposite infinities raises Invalid and returns the specialization default NaN. Exact cancellation returns +0 except under round-min, which returns -0. Finite inexact results may raise Inexact, Underflow, or Overflow | Inexact.

    F16::div

    fn F16::div(self : F16, context : Context, rhs : F16) -> SoftResult[F16]

    Divides two F16 values using the rounding mode carried by context.

    NaNs propagate. infinity / infinity and 0 / 0 raise Invalid and return the specialization default NaN. A finite nonzero dividend divided by zero raises Infinite and returns a signed infinity. A finite value divided by infinity returns signed zero.

    F16::from_bits

    fn F16::from_bits(bits : UInt16) -> F16

    Creates an F16 from its raw IEEE 754 binary16 bits.

    The bits are stored exactly as provided. NaN payloads are not quieted or canonicalized here, and no SoftFloat exception flags are raised.

    F16::is_signaling_nan

    fn F16::is_signaling_nan(self : F16) -> Bool

    Returns true when this F16 bit pattern is a signaling NaN.

    This is a pure classification helper. It does not quiet the NaN, does not canonicalize the payload, and raises no Invalid flag. Non-NaN values, infinities, and quiet NaNs return false.

    F16::mul

    fn F16::mul(self : F16, context : Context, rhs : F16) -> SoftResult[F16]

    Multiplies two F16 values using the rounding mode carried by context.

    NaNs propagate, with signaling NaNs raising Invalid. Multiplying zero by infinity raises Invalid and returns the specialization default NaN. Otherwise infinities and zeros keep the XOR of operand signs. Finite products are rounded in the supplied context and may raise the usual inexact, underflow, or overflow flags.

    F16::mul_add

    fn F16::mul_add(self : F16, context : Context, rhs : F16, addend : F16) -> SoftResult[F16]

    Computes fused (self * rhs) + addend for F16 values.

    Multiplication and addition are fused with a single final rounding. NaNs propagate, signaling NaNs raise Invalid, 0 * infinity raises Invalid, and an infinite product added to an opposite-signed infinity raises Invalid. Complete cancellation returns a signed zero selected by round-min versus the other rounding modes.

    F16::rem

    fn F16::rem(self : F16, context : Context, rhs : F16) -> SoftResult[F16]

    Computes the IEEE F16 remainder using the rounding mode carried by context.

    NaNs propagate. An infinite dividend or zero divisor raises Invalid; a finite dividend with an infinite divisor is returned unchanged. The quotient is rounded to nearest with even-tie handling as in SoftFloat f16_rem; the final remainder is normalized with the expected IEEE sign.

    F16::round_to_int

    fn F16::round_to_int(self : F16, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[F16]

    Rounds F16 to an integral F16 value with an operation-local rounding mode.

    This ports SoftFloat f16_roundToInt: exact controls whether rounded finite inputs raise Inexact; NaNs are propagated through the selected specialization. Infinities and finite values already integral are returned unchanged. Inputs with magnitude below 1 round to signed zero or signed one according to rounding; no overflow or underflow flag is raised.

    F16::sqrt

    fn F16::sqrt(self : F16, context : Context) -> SoftResult[F16]

    Computes the F16 square root using the rounding mode carried by context.

    NaNs propagate. +infinity and both signed zeros are returned unchanged. Negative nonzero finite values and -infinity raise Invalid and return the specialization default NaN. Inexact finite roots may raise Inexact.

    F16::sub

    fn F16::sub(self : F16, context : Context, rhs : F16) -> SoftResult[F16]

    Subtracts two F16 values using the rounding mode carried by context.

    This has the same boundary behavior as f16_sub: NaNs propagate, signaling NaNs raise Invalid, subtracting equal-signed infinities raises Invalid, and exact finite cancellation returns a signed zero selected by the rounding mode.

    F16::to_bits

    fn F16::to_bits(self : F16) -> UInt16

    Returns the raw IEEE 754 binary16 bits stored in this value.

    For values created with F16::from_bits, this is an exact round trip even for NaNs and signed zeros.

    F16::to_f32

    fn F16::to_f32(self : F16, context : Context) -> SoftResult[F32]

    Converts F16 to F32 with SoftFloat NaN and subnormal handling.

    The conversion is exact for all finite F16 inputs, including signed zeros and subnormals. Infinities keep their sign. NaNs use the selected specialization's common-NaN conversion; signaling NaNs raise Invalid.

    F16::to_f64

    fn F16::to_f64(self : F16, context : Context) -> SoftResult[F64]

    Converts F16 to F64 with SoftFloat NaN and subnormal handling.

    The conversion is exact for all finite F16 inputs, including signed zeros and subnormals. Infinities keep their sign. NaNs use the selected specialization's common-NaN conversion; signaling NaNs raise Invalid.

    F16::to_i32

    fn F16::to_i32(self : F16, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[Int]

    Converts F16 to signed 32-bit integer with operation-local rounding.

    Every finite F16 magnitude fits in Int32, so finite overflow is not a boundary case for this conversion. NaNs and infinities raise Invalid; finite fractional inputs raise Inexact only when exact is true.

    F16::to_i32_min_mag

    fn F16::to_i32_min_mag(self : F16, context : Context, exact : Bool) -> SoftResult[Int]

    Converts F16 to signed 32-bit integer with round-minMag.

    Finite values truncate toward zero and all fit in Int32. Values with magnitude below 1 return 0 and may raise Inexact; NaNs and infinities raise Invalid.

    F16::to_i64

    fn F16::to_i64(self : F16, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[Int64]

    Converts F16 to signed 64-bit integer with operation-local rounding.

    Every finite F16 value fits in Int64. NaNs and infinities raise Invalid; otherwise the requested rounding mode determines how fractional bits are discarded, and exact controls whether that loss raises Inexact.

    F16::to_i64_min_mag

    fn F16::to_i64_min_mag(self : F16, context : Context, exact : Bool) -> SoftResult[Int64]

    Converts F16 to signed 64-bit integer with round-minMag.

    Finite values truncate toward zero and all fit in Int64. exact controls the Inexact flag for discarded fractional bits; NaNs and infinities raise Invalid.

    F16::to_ui32

    fn F16::to_ui32(self : F16, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[UInt]

    Converts F16 to unsigned 32-bit integer with operation-local rounding.

    All nonnegative finite F16 values fit in UInt32. Negative zero converts to 0; negative nonzero values raise Invalid and return the specialization's unsigned negative-overflow result. NaNs and infinities raise Invalid. exact controls whether discarded fractional bits raise Inexact.

    F16::to_ui32_min_mag

    fn F16::to_ui32_min_mag(self : F16, context : Context, exact : Bool) -> SoftResult[UInt]

    Converts F16 to unsigned 32-bit integer with round-minMag.

    This is the SoftFloat _r_minMag form: finite values are truncated toward zero regardless of context.rounding. Magnitudes below 1 convert to 0 and may raise Inexact when exact is true. Negative nonzero values, NaNs, and infinities raise Invalid.

    F16::to_ui64

    fn F16::to_ui64(self : F16, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[UInt64]

    Converts F16 to unsigned 64-bit integer with operation-local rounding.

    All nonnegative finite F16 values fit in UInt64. Negative zero converts to 0; negative nonzero values, NaNs, and infinities raise Invalid and use specialization-defined invalid result constants. exact only controls Inexact for finite fractional inputs.

    F16::to_ui64_min_mag

    fn F16::to_ui64_min_mag(self : F16, context : Context, exact : Bool) -> SoftResult[UInt64]

    Converts F16 to unsigned 64-bit integer with round-minMag.

    Equivalent boundary behavior to F16::to_ui32_min_mag, but returning UInt64. All nonnegative finite F16 values are in range.

    F32

    pub struct F32(UInt)

    IEEE 754 binary32 bit wrapper used by SoftFloat operations.

    The stored value is the raw 32-bit payload. Native Float bridges only reinterpret bits and are not used to compute SoftFloat results. All binary32 encodings are accepted, including noncanonical NaN payloads.

    F32::add

    fn F32::add(self : F32, context : Context, rhs : F32) -> SoftResult[F32]

    Adds rhs to this F32 value using the explicit SoftFloat context.

    NaNs propagate, signaling NaNs raise Invalid, and opposite-signed infinities raise Invalid with the specialization default NaN. Exact cancellation returns +0 except under round-min, where it returns -0. Finite inexact results may raise Inexact, Underflow, or Overflow | Inexact.

    F32::div

    fn F32::div(self : F32, context : Context, rhs : F32) -> SoftResult[F32]

    Divides this F32 value by rhs using the explicit SoftFloat context.

    NaNs propagate. infinity / infinity and 0 / 0 raise Invalid. Nonzero finite division by zero raises Infinite and returns signed infinity. Finite division by infinity returns signed zero.

    F32::from_bits

    fn F32::from_bits(bits : UInt) -> F32

    Creates an F32 from its raw IEEE 754 binary32 bits.

    The payload is stored unchanged. This constructor does not raise flags and does not canonicalize signaling NaNs.

    F32::from_float_bits

    fn F32::from_float_bits(value : Float) -> F32

    Reinterprets a native Float bit pattern as an F32.

    This helper performs no arithmetic and raises no SoftFloat flags. Host NaNs are taken as their raw in-memory Float bit pattern; no SoftFloat NaN propagation rules are applied.

    F32::is_signaling_nan

    fn F32::is_signaling_nan(self : F32) -> Bool

    Returns true when this F32 bit pattern is a signaling NaN.

    Quiet NaNs, infinities, zeros, subnormals, and finite numbers return false. The value is not modified and no exception flags are raised.

    F32::mul

    fn F32::mul(self : F32, context : Context, rhs : F32) -> SoftResult[F32]

    Multiplies this F32 value by rhs using the explicit SoftFloat context.

    NaNs propagate, signaling NaNs raise Invalid, and 0 * infinity raises Invalid. Otherwise infinities and zeros use the XOR of operand signs. Finite products are rounded in the supplied context and may raise the usual rounding, underflow, and overflow flags.

    F32::mul_add

    fn F32::mul_add(self : F32, context : Context, rhs : F32, addend : F32) -> SoftResult[F32]

    Computes fused (self * rhs) + addend for F32 values.

    The product and addend are combined before a single final rounding. NaNs propagate, signaling NaNs raise Invalid, 0 * infinity raises Invalid, and an infinite product plus an opposite-signed infinity raises Invalid. Complete cancellation returns a signed zero selected by the rounding mode.

    F32::rem

    fn F32::rem(self : F32, context : Context, rhs : F32) -> SoftResult[F32]

    Computes the IEEE remainder of this F32 value divided by rhs.

    NaNs propagate. An infinite dividend or zero divisor raises Invalid; a finite dividend with an infinite divisor is returned unchanged. Quotient ties follow SoftFloat even-tie behavior, and the final remainder is normalized with the expected IEEE sign.

    F32::round_to_int

    fn F32::round_to_int(self : F32, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[F32]

    Rounds F32 to an integral F32 value with operation-local rounding.

    exact controls whether changed finite inputs raise Inexact; NaNs are propagated according to context.specialization. Infinities and already integral finite values are returned unchanged. Values with magnitude below 1 round to signed zero or signed one according to rounding; no overflow or underflow flag is raised.

    F32::sqrt

    fn F32::sqrt(self : F32, context : Context) -> SoftResult[F32]

    Computes the square root of this F32 value using the explicit context.

    NaNs propagate. +infinity and signed zeros are returned unchanged. Negative nonzero values and -infinity raise Invalid and return the specialization default NaN. Inexact finite roots may raise Inexact.

    F32::sub

    fn F32::sub(self : F32, context : Context, rhs : F32) -> SoftResult[F32]

    Subtracts rhs from this F32 value using the explicit SoftFloat context.

    NaNs propagate, signaling NaNs raise Invalid, and subtracting equal-signed infinities raises Invalid. Exact cancellation returns a signed zero chosen by the rounding mode.

    F32::to_bf16

    fn F32::to_bf16(self : F32, context : Context) -> SoftResult[BF16]

    Converts F32 to BF16 with SoftFloat rounding and NaN handling.

    Finite values are rounded through round_pack_to_bf16, so the returned context may accumulate Inexact, Underflow, or Overflow. NaNs use the selected specialization's common-NaN conversion and raise Invalid for signaling NaNs. Signed zeros and infinities keep their sign; overflow rounds to infinity or the largest finite BF16 according to context.rounding.

    F32::to_bits

    fn F32::to_bits(self : F32) -> UInt

    Returns the raw IEEE 754 binary32 bits stored in this value.

    The result preserves signs of zero and NaN payload bits exactly.

    F32::to_f16

    fn F32::to_f16(self : F32, context : Context) -> SoftResult[F16]

    Converts F32 to F16 with SoftFloat NaN, overflow, and subnormal handling.

    Signed zeros and infinities keep their sign. Finite values are rounded to binary16 according to the context and may raise Inexact, Underflow, or Overflow | Inexact; overflow returns infinity or the largest finite F16 as SoftFloat specifies. NaNs use specialization-specific propagation, and signaling NaNs raise Invalid.

    F32::to_f64

    fn F32::to_f64(self : F32, context : Context) -> SoftResult[F64]

    Converts F32 to F64 exactly for finite inputs.

    Signed zeros, subnormals, normals, and infinities are widened without rounding. NaNs are converted through the selected specialization; signaling NaNs raise Invalid.

    F32::to_float_bits

    fn F32::to_float_bits(self : F32) -> Float

    Reinterprets this F32 bit pattern as a native Float.

    This helper performs no arithmetic and raises no SoftFloat flags. The host runtime receives the raw bits, including NaN payloads and signed zeros.

    F32::to_i32

    fn F32::to_i32(self : F32, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[Int]

    Converts F32 to signed 32-bit integer with operation-local rounding.

    NaNs, infinities, and values outside the Int32 range after rounding raise Invalid. The exact value -2147483648 is valid. Fractional finite inputs raise Inexact only when exact is true.

    F32::to_i32_min_mag

    fn F32::to_i32_min_mag(self : F32, context : Context, exact : Bool) -> SoftResult[Int]

    Converts F32 to signed 32-bit integer using round-minMag.

    Finite values truncate toward zero. The exact lower bound -2147483648 is accepted; values beyond the Int32 range, NaNs, and infinities raise Invalid. exact controls Inexact for discarded fractional bits.

    F32::to_i64

    fn F32::to_i64(self : F32, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[Int64]

    Converts F32 to signed 64-bit integer with operation-local rounding.

    NaNs, infinities, and values outside Int64 after rounding raise Invalid. The exact value -9223372036854775808 is valid. exact controls only whether discarded finite fractional bits raise Inexact.

    F32::to_i64_min_mag

    fn F32::to_i64_min_mag(self : F32, context : Context, exact : Bool) -> SoftResult[Int64]

    Converts F32 to signed 64-bit integer using round-minMag.

    Finite values truncate toward zero. The exact lower bound -9223372036854775808 is accepted; values beyond the Int64 range, NaNs, and infinities raise Invalid.

    F32::to_ui32

    fn F32::to_ui32(self : F32, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[UInt]

    Converts F32 to unsigned 32-bit integer with operation-local rounding.

    exact controls whether rounded finite inputs raise Inexact. Negative nonzero values, NaNs, infinities, and values outside UInt32 after rounding raise Invalid; invalid integer constants follow context.specialization. Negative zero converts to 0.

    F32::to_ui32_min_mag

    fn F32::to_ui32_min_mag(self : F32, context : Context, exact : Bool) -> SoftResult[UInt]

    Converts F32 to unsigned 32-bit integer using round-minMag.

    This _r_minMag form truncates finite values toward zero regardless of context.rounding. Magnitudes below 1 return 0 and may raise Inexact. Negative nonzero values, NaNs, infinities, and out-of-range values raise Invalid.

    F32::to_ui64

    fn F32::to_ui64(self : F32, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[UInt64]

    Converts F32 to unsigned 64-bit integer with operation-local rounding.

    Negative nonzero values, NaNs, infinities, and values outside UInt64 after rounding raise Invalid; negative zero converts to 0. Fractional finite inputs raise Inexact according to exact.

    F32::to_ui64_min_mag

    fn F32::to_ui64_min_mag(self : F32, context : Context, exact : Bool) -> SoftResult[UInt64]

    Converts F32 to unsigned 64-bit integer using round-minMag.

    Finite values truncate toward zero. Values with magnitude below 1 return 0; negative nonzero, NaN, infinity, and out-of-range inputs raise Invalid.

    F64

    pub struct F64(UInt64)

    IEEE 754 binary64 bit wrapper used by SoftFloat operations.

    The stored value is the raw 64-bit payload. Native Double bridges only reinterpret bits and are not used to compute SoftFloat results. Every binary64 encoding is representable by this wrapper.

    F64::add

    fn F64::add(self : F64, context : Context, rhs : F64) -> SoftResult[F64]

    Adds rhs to this F64 value using the rounding/tininess and specialization carried by context.

    NaNs propagate, signaling NaNs raise Invalid, and adding opposite-signed infinities raises Invalid with the specialization default NaN. Exact cancellation returns +0 except under round-min, where it returns -0. Finite inexact results may raise Inexact, Underflow, or Overflow | Inexact.

    F64::div

    fn F64::div(self : F64, context : Context, rhs : F64) -> SoftResult[F64]

    Divides this F64 value by rhs using the explicit SoftFloat context.

    NaNs propagate. infinity / infinity and 0 / 0 raise Invalid. Nonzero finite division by zero raises Infinite and returns signed infinity. Finite division by infinity returns signed zero.

    F64::from_bits

    fn F64::from_bits(bits : UInt64) -> F64

    Creates an F64 from its raw IEEE 754 binary64 bits.

    The bits are stored as-is. This is safe for infinities, subnormals, signed zeros, and both quiet and signaling NaNs; no flags are raised.

    F64::from_double_bits

    fn F64::from_double_bits(value : Double) -> F64

    Reinterprets a native Double bit pattern as an F64.

    This helper performs no arithmetic and raises no SoftFloat flags. Host NaNs are captured by bit pattern, without SoftFloat canonicalization.

    F64::is_signaling_nan

    fn F64::is_signaling_nan(self : F64) -> Bool

    Returns true when this F64 bit pattern is a signaling NaN.

    This is a bit-level predicate only: it does not quiet signaling NaNs and does not raise Invalid.

    F64::mul

    fn F64::mul(self : F64, context : Context, rhs : F64) -> SoftResult[F64]

    Multiplies this F64 value by rhs using the explicit SoftFloat context.

    NaNs propagate, signaling NaNs raise Invalid, and 0 * infinity raises Invalid. Otherwise infinities and zeros use the XOR of operand signs. Finite products are rounded in the supplied context and may raise the usual rounding, underflow, and overflow flags.

    F64::mul_add

    fn F64::mul_add(self : F64, context : Context, rhs : F64, addend : F64) -> SoftResult[F64]

    Computes fused (self * rhs) + addend for F64 values.

    The multiplication and addition are fused before rounding, matching SoftFloat f64_mulAdd. NaNs propagate, signaling NaNs raise Invalid, 0 * infinity raises Invalid, and an infinite product plus an opposite-signed infinity raises Invalid. Complete cancellation returns a signed zero selected by the rounding mode.

    F64::rem

    fn F64::rem(self : F64, context : Context, rhs : F64) -> SoftResult[F64]

    Computes the IEEE remainder of this F64 value divided by rhs.

    NaNs propagate. An infinite dividend or zero divisor raises Invalid; a finite dividend with an infinite divisor is returned unchanged. Quotient ties follow SoftFloat even-tie behavior, and the final remainder preserves the expected IEEE sign.

    F64::round_to_int

    fn F64::round_to_int(self : F64, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[F64]

    Rounds F64 to an integral F64 value with operation-local rounding.

    exact controls whether a changed finite value raises Inexact; NaNs are propagated according to context.specialization. Infinities and already integral finite values are returned unchanged. Values with magnitude below 1 round to signed zero or signed one according to rounding; no overflow or underflow flag is raised.

    F64::sqrt

    fn F64::sqrt(self : F64, context : Context) -> SoftResult[F64]

    Computes the square root of this F64 value using the explicit context.

    NaNs propagate. +infinity and signed zeros are returned unchanged. Negative nonzero values and -infinity raise Invalid and return the specialization default NaN. Inexact finite roots may raise Inexact.

    F64::sub

    fn F64::sub(self : F64, context : Context, rhs : F64) -> SoftResult[F64]

    Subtracts rhs from this F64 value using the explicit SoftFloat context.

    NaNs propagate, signaling NaNs raise Invalid, and subtracting equal-signed infinities raises Invalid. Exact cancellation returns a signed zero chosen by the rounding mode.

    F64::to_bits

    fn F64::to_bits(self : F64) -> UInt64

    Returns the raw IEEE 754 binary64 bits stored in this value.

    This is an exact round trip for all values created by F64::from_bits.

    F64::to_double_bits

    fn F64::to_double_bits(self : F64) -> Double

    Reinterprets this F64 bit pattern as a native Double.

    This helper performs no arithmetic and raises no SoftFloat flags. The host runtime receives exactly the stored binary64 bits.

    F64::to_f16

    fn F64::to_f16(self : F64, context : Context) -> SoftResult[F16]

    Converts F64 to F16 with SoftFloat rounding, tininess, and NaN handling.

    Signaling NaNs raise Invalid; finite values may raise Inexact, Underflow, or Overflow | Inexact as they round into binary16. Signed zeros and infinities keep their sign. Overflow returns infinity or the largest finite F16 according to context.rounding.

    F64::to_f32

    fn F64::to_f32(self : F64, context : Context) -> SoftResult[F32]

    Converts F64 to F32 with SoftFloat rounding, tininess, and NaN handling.

    The selected specialization controls NaN payload/default behavior and signaling-NaN invalid flags. Signed zeros and infinities keep their sign. Finite values may raise Inexact, Underflow, or Overflow | Inexact; overflow follows the destination format's rounding rules.

    F64::to_i32

    fn F64::to_i32(self : F64, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[Int]

    Converts F64 to signed 32-bit integer with operation-local rounding.

    NaNs, infinities, and values outside Int32 after rounding raise Invalid. The exact value -2147483648 is valid. Invalid integer result constants follow context.specialization; exact only controls finite fractional Inexact.

    F64::to_i32_min_mag

    fn F64::to_i32_min_mag(self : F64, context : Context, exact : Bool) -> SoftResult[Int]

    Converts F64 to signed 32-bit integer using round-minMag.

    Finite values truncate toward zero. The exact lower bound -2147483648 is accepted; values beyond Int32, NaNs, and infinities raise Invalid. exact controls Inexact for discarded fractional bits.

    F64::to_i64

    fn F64::to_i64(self : F64, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[Int64]

    Converts F64 to signed 64-bit integer with operation-local rounding.

    NaNs, infinities, and values outside Int64 after rounding raise Invalid. The exact lower bound -9223372036854775808 is accepted. Invalid result constants follow context.specialization.

    F64::to_i64_min_mag

    fn F64::to_i64_min_mag(self : F64, context : Context, exact : Bool) -> SoftResult[Int64]

    Converts F64 to signed 64-bit integer using round-minMag.

    Finite values truncate toward zero. The exact lower bound -9223372036854775808 is accepted; values beyond Int64, NaNs, and infinities raise Invalid. exact controls Inexact for discarded fractional bits.

    F64::to_ui32

    fn F64::to_ui32(self : F64, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[UInt]

    Converts F64 to unsigned 32-bit integer with operation-local rounding.

    exact controls whether rounded finite inputs raise Inexact; NaNs, negative nonzero values, infinities, and values outside UInt32 after rounding raise Invalid. Negative zero converts to 0; invalid result constants follow the selected specialization.

    F64::to_ui32_min_mag

    fn F64::to_ui32_min_mag(self : F64, context : Context, exact : Bool) -> SoftResult[UInt]

    Converts F64 to unsigned 32-bit integer using round-minMag.

    This _r_minMag form truncates finite values toward zero regardless of context.rounding. Magnitudes below 1 return 0 and may raise Inexact. Negative nonzero values, NaNs, infinities, and out-of-range values raise Invalid.

    F64::to_ui64

    fn F64::to_ui64(self : F64, context : Context, rounding : RoundingMode, exact : Bool) -> SoftResult[UInt64]

    Converts F64 to unsigned 64-bit integer with operation-local rounding.

    Negative nonzero values, NaNs, infinities, and values outside UInt64 after rounding raise Invalid; negative zero converts to 0. Fractional finite inputs raise Inexact only when exact is true.

    F64::to_ui64_min_mag

    fn F64::to_ui64_min_mag(self : F64, context : Context, exact : Bool) -> SoftResult[UInt64]

    Converts F64 to unsigned 64-bit integer using round-minMag.

    Finite values truncate toward zero. Magnitudes below 1 return 0; negative nonzero, NaN, infinity, and out-of-range inputs raise Invalid.

    RoundingMode

    pub(all) enum RoundingMode {
    NearEven
    MinMag
    Min
    Max
    NearMaxMag
    Odd
    } derive(Eq)

    SoftFloat rounding modes.

    NearEven rounds to the nearest representable value and breaks exact half-way ties toward an even low bit. NearMaxMag also rounds to nearest but breaks half-way ties away from zero. MinMag truncates toward zero, Min rounds toward negative infinity, Max rounds toward positive infinity, and Odd uses the SoftFloat round-to-odd rule: after truncating, any inexact result is forced to have an odd least significant bit.

    Numeric mappings follow softfloat.h: NearEven=0, MinMag=1, Min=2, Max=3, NearMaxMag=4, and Odd=6. The gap at code 5 is intentional.

    RoundingMode::equal

    RoundingMode::not_equal

    fn RoundingMode::not_equal(x : RoundingMode, y : RoundingMode) -> Bool

    SoftResult

    pub(all) struct SoftResult[T] {
    value : T
    context : Context
    }

    Result of a SoftFloat operation paired with the updated explicit context.

    Operations that can raise IEEE flags return this shape instead of mutating global SoftFloat state. value is the operation result, while context contains the original context with any newly raised flags accumulated. Exact operations usually return the input context unchanged.

    Specialization

    pub(all) enum Specialization {
    X86_8086SSE
    RISCV
    } derive(Eq)

    SoftFloat specialization profile.

    v1 models the Release 3e 8086-SSE and RISCV profiles. The profile controls default NaN bit patterns, NaN payload propagation, and the integer value returned when a float-to-integer conversion raises Invalid. It does not change the public function signatures or make flags global.

    Specialization::equal

    Specialization::not_equal

    fn Specialization::not_equal(x : Specialization, y : Specialization) -> Bool

    TininessMode

    pub(all) enum TininessMode {
    BeforeRounding
    AfterRounding
    } derive(Eq)

    SoftFloat underflow tininess detection mode.

    This setting only controls when an operation raises the Underflow flag; it does not change the mathematical operation being requested. In BeforeRounding mode, tininess may be reported before final rounding can rescue a result into the normal range. In AfterRounding mode, tininess is tested on the rounded result, matching the default context.

    Numeric mappings follow softfloat.h: BeforeRounding=0 and AfterRounding=1.

    TininessMode::equal

    TininessMode::not_equal

    fn TininessMode::not_equal(x : TininessMode, y : TininessMode) -> Bool

    bf16_is_signaling_nan

    fn bf16_is_signaling_nan(a : BF16) -> Bool

    Function-style BF16 signaling-NaN predicate wrapper.

    Equivalent to a.is_signaling_nan() and raises no flags.

    bf16_to_f32

    fn bf16_to_f32(context : Context, a : BF16) -> SoftResult[F32]

    Function-style BF16-to-F32 wrapper for the SoftFloat C symbol.

    Equivalent to a.to_f32(context); no additional flags or canonicalization are applied beyond the method behavior.

    f16_add

    fn f16_add(context : Context, a : F16, b : F16) -> SoftResult[F16]

    Function-style F16 addition wrapper for the SoftFloat C symbol.

    Equivalent to a.add(context, b), including NaN, infinity, signed-zero, and rounding flag behavior.

    f16_div

    fn f16_div(context : Context, a : F16, b : F16) -> SoftResult[F16]

    Function-style F16 division wrapper for the SoftFloat C symbol.

    Equivalent to a.div(context, b).

    f16_eq

    fn f16_eq(context : Context, a : F16, b : F16) -> SoftResult[Bool]

    Implements SoftFloat f16_eq.

    Quiet NaNs compare false without raising flags; signaling NaNs raise Invalid and compare false. +0 and -0 compare equal.

    f16_eq_signaling

    fn f16_eq_signaling(context : Context, a : F16, b : F16) -> SoftResult[Bool]

    Implements SoftFloat f16_eq_signaling.

    Any NaN operand raises Invalid and compares false. +0 and -0 compare equal.

    f16_is_signaling_nan

    fn f16_is_signaling_nan(a : F16) -> Bool

    Function-style F16 signaling-NaN predicate wrapper.

    Equivalent to a.is_signaling_nan() and raises no flags.

    f16_le

    fn f16_le(context : Context, a : F16, b : F16) -> SoftResult[Bool]

    Implements SoftFloat f16_le.

    Any NaN operand raises Invalid and returns false. Signed zeros compare equal, so both +0 <= -0 and -0 <= +0 are true.

    f16_le_quiet

    fn f16_le_quiet(context : Context, a : F16, b : F16) -> SoftResult[Bool]

    Implements SoftFloat f16_le_quiet.

    Quiet NaNs return false without flags; signaling NaNs raise Invalid. Signed zeros compare equal.

    f16_lt

    fn f16_lt(context : Context, a : F16, b : F16) -> SoftResult[Bool]

    Implements SoftFloat f16_lt.

    Any NaN operand raises Invalid and returns false. Signed zeros compare equal, so neither zero is less than the other.

    f16_lt_quiet

    fn f16_lt_quiet(context : Context, a : F16, b : F16) -> SoftResult[Bool]

    Implements SoftFloat f16_lt_quiet.

    Quiet NaNs return false without flags; signaling NaNs raise Invalid. Signed zeros compare equal, so zero-vs-zero is never less-than.

    f16_mul

    fn f16_mul(context : Context, a : F16, b : F16) -> SoftResult[F16]

    Function-style F16 multiplication wrapper for the SoftFloat C symbol.

    Equivalent to a.mul(context, b).

    f16_mul_add

    fn f16_mul_add(context : Context, a : F16, b : F16, c : F16) -> SoftResult[F16]

    Function-style fused F16 multiply-add wrapper for f16_mulAdd.

    Equivalent to a.mul_add(context, b, c).

    f16_rem

    fn f16_rem(context : Context, a : F16, b : F16) -> SoftResult[F16]

    Function-style F16 remainder wrapper for the SoftFloat C symbol.

    Equivalent to a.rem(context, b).

    f16_round_to_int

    fn f16_round_to_int(context : Context, a : F16, rounding : RoundingMode, exact : Bool) -> SoftResult[F16]

    Function-style F16 round-to-integral wrapper for the SoftFloat C symbol.

    Equivalent to a.round_to_int(context, rounding, exact).

    f16_sqrt

    fn f16_sqrt(context : Context, a : F16) -> SoftResult[F16]

    Function-style F16 square-root wrapper for the SoftFloat C symbol.

    Equivalent to a.sqrt(context).

    f16_sub

    fn f16_sub(context : Context, a : F16, b : F16) -> SoftResult[F16]

    Function-style F16 subtraction wrapper for the SoftFloat C symbol.

    Equivalent to a.sub(context, b).

    f16_to_f32

    fn f16_to_f32(context : Context, a : F16) -> SoftResult[F32]

    Function-style F16-to-F32 wrapper for the SoftFloat C symbol.

    Equivalent to a.to_f32(context), including exact finite conversion and signaling-NaN invalid flag behavior.

    f16_to_f64

    fn f16_to_f64(context : Context, a : F16) -> SoftResult[F64]

    Function-style F16-to-F64 wrapper for the SoftFloat C symbol.

    Equivalent to a.to_f64(context) with no extra rounding or flag handling.

    f16_to_i32

    fn f16_to_i32(context : Context, a : F16, rounding : RoundingMode, exact : Bool) -> SoftResult[Int]

    Function-style wrapper for SoftFloat f16_to_i32.

    Equivalent to a.to_i32(context, rounding, exact).

    f16_to_i32_min_mag

    fn f16_to_i32_min_mag(context : Context, a : F16, exact : Bool) -> SoftResult[Int]

    Function-style wrapper for SoftFloat f16_to_i32_r_minMag.

    Equivalent to a.to_i32_min_mag(context, exact).

    f16_to_i64

    fn f16_to_i64(context : Context, a : F16, rounding : RoundingMode, exact : Bool) -> SoftResult[Int64]

    Function-style wrapper for SoftFloat f16_to_i64.

    Equivalent to a.to_i64(context, rounding, exact).

    f16_to_i64_min_mag

    fn f16_to_i64_min_mag(context : Context, a : F16, exact : Bool) -> SoftResult[Int64]

    Function-style wrapper for SoftFloat f16_to_i64_r_minMag.

    Equivalent to a.to_i64_min_mag(context, exact).

    f16_to_ui32

    fn f16_to_ui32(context : Context, a : F16, rounding : RoundingMode, exact : Bool) -> SoftResult[UInt]

    Function-style wrapper for SoftFloat f16_to_ui32.

    Equivalent to a.to_ui32(context, rounding, exact).

    f16_to_ui32_min_mag

    fn f16_to_ui32_min_mag(context : Context, a : F16, exact : Bool) -> SoftResult[UInt]

    Function-style wrapper for SoftFloat f16_to_ui32_r_minMag.

    Equivalent to a.to_ui32_min_mag(context, exact).

    f16_to_ui64

    fn f16_to_ui64(context : Context, a : F16, rounding : RoundingMode, exact : Bool) -> SoftResult[UInt64]

    Function-style wrapper for SoftFloat f16_to_ui64.

    Equivalent to a.to_ui64(context, rounding, exact).

    f16_to_ui64_min_mag

    fn f16_to_ui64_min_mag(context : Context, a : F16, exact : Bool) -> SoftResult[UInt64]

    Function-style wrapper for SoftFloat f16_to_ui64_r_minMag.

    Equivalent to a.to_ui64_min_mag(context, exact).

    f32_add

    fn f32_add(context : Context, a : F32, b : F32) -> SoftResult[F32]

    Function-style wrapper for SoftFloat f32_add.

    Equivalent to a.add(context, b).

    f32_div

    fn f32_div(context : Context, a : F32, b : F32) -> SoftResult[F32]

    Function-style wrapper for SoftFloat f32_div.

    Equivalent to a.div(context, b).

    f32_eq

    fn f32_eq(context : Context, a : F32, b : F32) -> SoftResult[Bool]

    Implements SoftFloat f32_eq.

    Quiet NaNs compare false; signaling NaNs raise Invalid. +0 and -0 compare equal.

    f32_eq_signaling

    fn f32_eq_signaling(context : Context, a : F32, b : F32) -> SoftResult[Bool]

    Implements SoftFloat f32_eq_signaling.

    Any NaN operand raises Invalid and compares false. +0 and -0 compare equal.

    f32_is_signaling_nan

    fn f32_is_signaling_nan(a : F32) -> Bool

    Function-style F32 signaling-NaN predicate wrapper.

    Equivalent to a.is_signaling_nan() and raises no flags.

    f32_le

    fn f32_le(context : Context, a : F32, b : F32) -> SoftResult[Bool]

    Implements SoftFloat f32_le.

    Any NaN operand raises Invalid and compares false. Signed zeros compare equal, so both zero orderings are true for less-or-equal.

    f32_le_quiet

    fn f32_le_quiet(context : Context, a : F32, b : F32) -> SoftResult[Bool]

    Implements SoftFloat f32_le_quiet.

    Quiet NaNs compare false without flags; signaling NaNs raise Invalid. Signed zeros compare equal.

    f32_lt

    fn f32_lt(context : Context, a : F32, b : F32) -> SoftResult[Bool]

    Implements SoftFloat f32_lt.

    Any NaN operand raises Invalid and compares false. Signed zeros compare equal, so neither zero is less than the other.

    f32_lt_quiet

    fn f32_lt_quiet(context : Context, a : F32, b : F32) -> SoftResult[Bool]

    Implements SoftFloat f32_lt_quiet.

    Quiet NaNs compare false without flags; signaling NaNs raise Invalid. Signed zeros compare equal, so zero-vs-zero is never less-than.

    f32_mul

    fn f32_mul(context : Context, a : F32, b : F32) -> SoftResult[F32]

    Function-style wrapper for SoftFloat f32_mul.

    Equivalent to a.mul(context, b).

    f32_mul_add

    fn f32_mul_add(context : Context, a : F32, b : F32, c : F32) -> SoftResult[F32]

    Function-style wrapper for SoftFloat f32_mulAdd.

    Equivalent to a.mul_add(context, b, c).

    f32_rem

    fn f32_rem(context : Context, a : F32, b : F32) -> SoftResult[F32]

    Function-style wrapper for SoftFloat f32_rem.

    Equivalent to a.rem(context, b).

    f32_round_to_int

    fn f32_round_to_int(context : Context, a : F32, rounding : RoundingMode, exact : Bool) -> SoftResult[F32]

    Function-style F32 round-to-integral wrapper for f32_roundToInt.

    Equivalent to a.round_to_int(context, rounding, exact).

    f32_sqrt

    fn f32_sqrt(context : Context, a : F32) -> SoftResult[F32]

    Function-style wrapper for SoftFloat f32_sqrt.

    Equivalent to a.sqrt(context).

    f32_sub

    fn f32_sub(context : Context, a : F32, b : F32) -> SoftResult[F32]

    Function-style wrapper for SoftFloat f32_sub.

    Equivalent to a.sub(context, b).

    f32_to_bf16

    fn f32_to_bf16(context : Context, a : F32) -> SoftResult[BF16]

    Function-style F32-to-BF16 wrapper for the SoftFloat C symbol.

    Equivalent to a.to_bf16(context), including NaN handling and all rounding flags.

    f32_to_f16

    fn f32_to_f16(context : Context, a : F32) -> SoftResult[F16]

    Function-style wrapper for SoftFloat f32_to_f16.

    Equivalent to a.to_f16(context).

    f32_to_f64

    fn f32_to_f64(context : Context, a : F32) -> SoftResult[F64]

    Function-style wrapper for SoftFloat f32_to_f64.

    Equivalent to a.to_f64(context).

    f32_to_i32

    fn f32_to_i32(context : Context, a : F32, rounding : RoundingMode, exact : Bool) -> SoftResult[Int]

    Function-style wrapper for SoftFloat f32_to_i32.

    Equivalent to a.to_i32(context, rounding, exact).

    f32_to_i32_min_mag

    fn f32_to_i32_min_mag(context : Context, a : F32, exact : Bool) -> SoftResult[Int]

    Function-style wrapper for SoftFloat f32_to_i32_r_minMag.

    Equivalent to a.to_i32_min_mag(context, exact).

    f32_to_i64

    fn f32_to_i64(context : Context, a : F32, rounding : RoundingMode, exact : Bool) -> SoftResult[Int64]

    Function-style wrapper for SoftFloat f32_to_i64.

    Equivalent to a.to_i64(context, rounding, exact).

    f32_to_i64_min_mag

    fn f32_to_i64_min_mag(context : Context, a : F32, exact : Bool) -> SoftResult[Int64]

    Function-style wrapper for SoftFloat f32_to_i64_r_minMag.

    Equivalent to a.to_i64_min_mag(context, exact).

    f32_to_ui32

    fn f32_to_ui32(context : Context, a : F32, rounding : RoundingMode, exact : Bool) -> SoftResult[UInt]

    Function-style wrapper for SoftFloat f32_to_ui32.

    Equivalent to a.to_ui32(context, rounding, exact).

    f32_to_ui32_min_mag

    fn f32_to_ui32_min_mag(context : Context, a : F32, exact : Bool) -> SoftResult[UInt]

    Function-style wrapper for SoftFloat f32_to_ui32_r_minMag.

    Equivalent to a.to_ui32_min_mag(context, exact).

    f32_to_ui64

    fn f32_to_ui64(context : Context, a : F32, rounding : RoundingMode, exact : Bool) -> SoftResult[UInt64]

    Function-style wrapper for SoftFloat f32_to_ui64.

    Equivalent to a.to_ui64(context, rounding, exact).

    f32_to_ui64_min_mag

    fn f32_to_ui64_min_mag(context : Context, a : F32, exact : Bool) -> SoftResult[UInt64]

    Function-style wrapper for SoftFloat f32_to_ui64_r_minMag.

    Equivalent to a.to_ui64_min_mag(context, exact).

    f64_add

    fn f64_add(context : Context, a : F64, b : F64) -> SoftResult[F64]

    Function-style wrapper for SoftFloat f64_add.

    The returned context accumulates IEEE flags including Invalid for infinity cancellation and Inexact/Overflow/Underflow from rounding. This is equivalent to a.add(context, b).

    f64_div

    fn f64_div(context : Context, a : F64, b : F64) -> SoftResult[F64]

    Function-style wrapper for SoftFloat f64_div.

    Division by zero raises Infinite for nonzero numerators and Invalid for 0 / 0; NaNs are propagated according to the selected specialization. This is equivalent to a.div(context, b).

    f64_eq

    fn f64_eq(context : Context, a : F64, b : F64) -> SoftResult[Bool]

    Implements SoftFloat f64_eq.

    Quiet NaNs compare false; signaling NaNs raise Invalid. +0 and -0 compare equal.

    f64_eq_signaling

    fn f64_eq_signaling(context : Context, a : F64, b : F64) -> SoftResult[Bool]

    Implements SoftFloat f64_eq_signaling.

    Any NaN operand raises Invalid and compares false. +0 and -0 compare equal.

    f64_is_signaling_nan

    fn f64_is_signaling_nan(a : F64) -> Bool

    Function-style F64 signaling-NaN predicate wrapper.

    Equivalent to a.is_signaling_nan() and raises no flags.

    f64_le

    fn f64_le(context : Context, a : F64, b : F64) -> SoftResult[Bool]

    Implements SoftFloat f64_le.

    Any NaN operand raises Invalid and compares false. Signed zeros compare equal, so both zero orderings are true for less-or-equal.

    f64_le_quiet

    fn f64_le_quiet(context : Context, a : F64, b : F64) -> SoftResult[Bool]

    Implements SoftFloat f64_le_quiet.

    Quiet NaNs compare false without flags; signaling NaNs raise Invalid. Signed zeros compare equal.

    f64_lt

    fn f64_lt(context : Context, a : F64, b : F64) -> SoftResult[Bool]

    Implements SoftFloat f64_lt.

    Any NaN operand raises Invalid and compares false. Signed zeros compare equal, so neither zero is less than the other.

    f64_lt_quiet

    fn f64_lt_quiet(context : Context, a : F64, b : F64) -> SoftResult[Bool]

    Implements SoftFloat f64_lt_quiet.

    Quiet NaNs compare false without flags; signaling NaNs raise Invalid. Signed zeros compare equal, so zero-vs-zero is never less-than.

    f64_mul

    fn f64_mul(context : Context, a : F64, b : F64) -> SoftResult[F64]

    Function-style wrapper for SoftFloat f64_mul.

    0 * infinity raises Invalid; finite products round according to context.rounding and use tininess detection from context.tininess. This is equivalent to a.mul(context, b).

    f64_mul_add

    fn f64_mul_add(context : Context, a : F64, b : F64, c : F64) -> SoftResult[F64]

    Function-style wrapper for SoftFloat f64_mulAdd.

    The returned context captures invalid infinity/zero products, infinity cancellation, NaN propagation, and final rounding flags. This is equivalent to a.mul_add(context, b, c).

    f64_rem

    fn f64_rem(context : Context, a : F64, b : F64) -> SoftResult[F64]

    Function-style wrapper for SoftFloat f64_rem.

    Infinite dividends and zero divisors raise Invalid; finite dividends with infinite divisors are returned unchanged. This is equivalent to a.rem(context, b).

    f64_round_to_int

    fn f64_round_to_int(context : Context, a : F64, rounding : RoundingMode, exact : Bool) -> SoftResult[F64]

    Function-style F64 round-to-integral wrapper for f64_roundToInt.

    Equivalent to a.round_to_int(context, rounding, exact).

    f64_sqrt

    fn f64_sqrt(context : Context, a : F64) -> SoftResult[F64]

    Function-style wrapper for SoftFloat f64_sqrt.

    Negative nonzero inputs raise Invalid; signed negative zero is returned unchanged. Finite non-square roots may raise Inexact. This is equivalent to a.sqrt(context).

    f64_sub

    fn f64_sub(context : Context, a : F64, b : F64) -> SoftResult[F64]

    Function-style wrapper for SoftFloat f64_sub.

    NaN propagation and invalid-result defaults follow context.specialization. This is equivalent to a.sub(context, b).

    f64_to_f16

    fn f64_to_f16(context : Context, a : F64) -> SoftResult[F16]

    Function-style wrapper for SoftFloat f64_to_f16.

    Equivalent to a.to_f16(context).

    f64_to_f32

    fn f64_to_f32(context : Context, a : F64) -> SoftResult[F32]

    Function-style wrapper for SoftFloat f64_to_f32.

    Equivalent to a.to_f32(context).

    f64_to_i32

    fn f64_to_i32(context : Context, a : F64, rounding : RoundingMode, exact : Bool) -> SoftResult[Int]

    Function-style wrapper for SoftFloat f64_to_i32.

    Equivalent to a.to_i32(context, rounding, exact).

    f64_to_i32_min_mag

    fn f64_to_i32_min_mag(context : Context, a : F64, exact : Bool) -> SoftResult[Int]

    Function-style wrapper for SoftFloat f64_to_i32_r_minMag.

    Equivalent to a.to_i32_min_mag(context, exact).

    f64_to_i64

    fn f64_to_i64(context : Context, a : F64, rounding : RoundingMode, exact : Bool) -> SoftResult[Int64]

    Function-style wrapper for SoftFloat f64_to_i64.

    Equivalent to a.to_i64(context, rounding, exact).

    f64_to_i64_min_mag

    fn f64_to_i64_min_mag(context : Context, a : F64, exact : Bool) -> SoftResult[Int64]

    Function-style wrapper for SoftFloat f64_to_i64_r_minMag.

    Equivalent to a.to_i64_min_mag(context, exact).

    f64_to_ui32

    fn f64_to_ui32(context : Context, a : F64, rounding : RoundingMode, exact : Bool) -> SoftResult[UInt]

    Function-style wrapper for SoftFloat f64_to_ui32.

    Equivalent to a.to_ui32(context, rounding, exact).

    f64_to_ui32_min_mag

    fn f64_to_ui32_min_mag(context : Context, a : F64, exact : Bool) -> SoftResult[UInt]

    Function-style wrapper for SoftFloat f64_to_ui32_r_minMag.

    Equivalent to a.to_ui32_min_mag(context, exact).

    f64_to_ui64

    fn f64_to_ui64(context : Context, a : F64, rounding : RoundingMode, exact : Bool) -> SoftResult[UInt64]

    Function-style wrapper for SoftFloat f64_to_ui64.

    Equivalent to a.to_ui64(context, rounding, exact).

    f64_to_ui64_min_mag

    fn f64_to_ui64_min_mag(context : Context, a : F64, exact : Bool) -> SoftResult[UInt64]

    Function-style wrapper for SoftFloat f64_to_ui64_r_minMag.

    Equivalent to a.to_ui64_min_mag(context, exact).

    i32_to_f16

    fn i32_to_f16(context : Context, a : Int) -> SoftResult[F16]

    Converts a signed 32-bit integer to F16.

    Integer zero produces positive zero. The most-negative Int is handled without taking a host abs. Nonrepresentable magnitudes round according to the context and may raise Inexact or Overflow | Inexact, but never Invalid.

    i32_to_f32

    fn i32_to_f32(context : Context, a : Int) -> SoftResult[F32]

    Converts a signed 32-bit integer to F32.

    The minimum Int is converted by bit magnitude rather than host absolute value. All results are finite; only precision loss can raise Inexact.

    i32_to_f64

    fn i32_to_f64(context : Context, a : Int) -> SoftResult[F64]

    Converts a signed 32-bit integer to F64 exactly.

    Every Int32 value, including the minimum value, is exactly representable in binary64. The result is finite and raises no flags.

    i64_to_f16

    fn i64_to_f16(context : Context, a : Int64) -> SoftResult[F16]

    Converts a signed 64-bit integer to F16.

    The sign is preserved for nonzero values, including the minimum Int64. Values too large for binary16 raise Overflow | Inexact; other inexact conversions raise Inexact. No NaN or invalid conversion is possible from an integer source.

    i64_to_f32

    fn i64_to_f32(context : Context, a : Int64) -> SoftResult[F32]

    Converts a signed 64-bit integer to F32 with SoftFloat rounding.

    The sign is preserved for nonzero inputs, including the minimum Int64. The result never overflows F32; precision loss is reported with Inexact.

    i64_to_f64

    fn i64_to_f64(context : Context, a : Int64) -> SoftResult[F64]

    Converts a signed 64-bit integer to F64 with SoftFloat rounding.

    The full Int64 range is finite in binary64. Values whose magnitude needs more than 53 precision bits may raise Inexact; no Invalid or Overflow flag is raised.

    ui32_to_f16

    fn ui32_to_f16(context : Context, a : UInt) -> SoftResult[F16]

    Converts an unsigned 32-bit integer to F16.

    Zero converts exactly to positive zero. Values that fit exactly in binary16 leave the context unchanged; values that need rounding may raise Inexact. Large inputs may overflow to infinity or the largest finite F16 according to context.rounding, raising Overflow | Inexact. This conversion never raises Invalid.

    ui32_to_f32

    fn ui32_to_f32(context : Context, a : UInt) -> SoftResult[F32]

    Converts an unsigned 32-bit integer to F32.

    Zero converts exactly to positive zero. Values with more precision than binary32 can store are rounded according to context.rounding and may raise Inexact; the UInt32 range never overflows F32.

    ui32_to_f64

    fn ui32_to_f64(context : Context, a : UInt) -> SoftResult[F64]

    Converts an unsigned 32-bit integer to F64 exactly.

    Every UInt32 value is exactly representable in binary64, so the returned context is unchanged.

    ui64_to_f16

    fn ui64_to_f16(context : Context, a : UInt64) -> SoftResult[F16]

    Converts an unsigned 64-bit integer to F16.

    Zero is exact. Any nonzero value is rounded according to context.rounding; results outside the finite F16 range raise Overflow | Inexact and return either signed infinity or the maximum finite value as SoftFloat specifies.

    ui64_to_f32

    fn ui64_to_f32(context : Context, a : UInt64) -> SoftResult[F32]

    Converts an unsigned 64-bit integer to F32 with SoftFloat rounding.

    Zero is exact. Large integer magnitudes remain finite in F32, but most values above the binary32 precision range raise Inexact after rounding.

    ui64_to_f64

    fn ui64_to_f64(context : Context, a : UInt64) -> SoftResult[F64]

    Converts an unsigned 64-bit integer to F64 with SoftFloat rounding.

    Values up to the binary64 precision limit are exact. Larger values are rounded according to context.rounding and may raise Inexact; UInt64 inputs never overflow F64.