floating

    Arbitrary-precision binary, decimal, and ball arithmetic for MoonBit, with checked operations and explicit numeric semantics.

    floating-point
    arbitrary-precision
    decimal
    interval
    ieee-754
    Download zip
    Author
    Version
    0.8.0
    License
    Apache-2.0
    Last updated
    3 hours ago
    Downloads
    74

    #FLOATING

    Maintainer License State

    Luna-Flow/floating 0.8.0 provides arbitrary-precision binary, decimal, GDA decimal, and certified interval arithmetic for MoonBit. Precision, rounding, special values, status flags, traps, and enclosure semantics are explicit rather than hidden in process-global state.

    #Start Here

    #Install

    moon add Luna-Flow/floating@0.8.0

    Import only the packages used by the current MoonBit package:

    import {
    "Luna-Flow/floating/bin_float"
    "Luna-Flow/floating/decimal"
    "Luna-Flow/floating/decimal_gda"
    "Luna-Flow/floating/ball_float"
    }

    #Quick Start

    ///|
    test "floating 0.8.0 quick start" {
    let binary = @bin_float.BinFloat::make(
    @bin_float.BinCoeff::from_uint64(3UL),
    -1,
    53,
    )
    inspect(binary.to_double(), content="1.5")

    let context = @decimal.DecimalContext::decimal64()
    let (decimal, flags) = @decimal.Decimal::from_string_ctx("12.3400", context)
    inspect(decimal.quantum(), content="-4")
    inspect(flags.has_error(), content="false")

    let interval = @ball_float.BallFloat::from_bounds(
    @bin_float.BinFloat::from_int(1, precision=53),
    @bin_float.BinFloat::from_int(2, precision=53),
    )
    inspect(interval.contains(binary), content="true")
    }

    The three values have different contracts: binary is one exact dyadic point, decimal retains the input quantum, and interval denotes every real value in [1, 2].

    #Package Guide

    RequirementPackageResult modelDocumentation
    arbitrary-precision dyadic and IEEE binary interchangebin_floatvalue or (value, BinaryFlags)API · Tutorial · Design
    IEEE decimal and DPD/BID interchangedecimalvalue or (value, DecimalFlags)API · Tutorial · Design
    General Decimal Arithmetic status and trapsdecimal_gdaGdaOutcome with defined result and next contextAPI · Tutorial · Design · Performance
    certified real enclosure and IEEE 1788 decorationsball_floatbare/decorated interval, optionally with BallFlagsAPI · Tutorial · Design · Performance
    first-error binary pipelinebin_float_checkedResult[BinFloat, ArithmeticError] wrapperTutorial
    accumulated IEEE decimal pipelinedecimal_checkedvalue + latest/combined flags + optional certification errorTutorial
    sticky/trapping GDA pipelinedecimal_gda_checkedone threaded GdaOutcomeTutorial
    first-error interval pipelineball_float_checkedResult[BallFloat, ArithmeticError] wrapperTutorial
    representation-independent observationsemanticexact scalar/interval projectionAPI

    Parser, CLI, benchmark, consistency, and internal/* packages are repository infrastructure. See the full documentation index before depending on them as application APIs.

    #0.8.0 At A Glance

    • BinFloat, Decimal, and BallFloat expose certified elementary-function paths with bounded refinement and structured certification failure.
    • Binary and decimal coefficient kernels use target-specific, exact-fallback dispatch across schoolbook, Karatsuba, Toom-3, NTT, block division, and reciprocal algorithms.
    • decimal and decimal_gda are independent state models: IEEE per-operation flags are not GDA sticky status/traps.
    • BinFloat implements the contextual arithmetic traits, so binary, IEEE decimal, and GDA decimal all compose through the same ArithmeticContext.
    • Converting an ArithmeticContext into a binary or decimal context now carries e_min, e_max, and clamp; contextual operations honour the caller's exponent range instead of running unbounded.
    • ball_float covers the declared strict IEEE 1788 phases with bare/decorated intervals, critical-point/pole handling, and conservative total fallbacks.
    • Benchmarks moved into the unified bench/* Maremark hierarchy with explicit crossover and regression analysis.
    • The 0.7.1 optimization audit records exact-kernel, directed-rounding, and interval-monotonicity proofs for the optimized paths.
    • The native benchmark artifact covers all four core suites; non-monotonic auto-tune observations remain evidence only until independently replicated.

    Detailed claims and exclusions live in package-local evidence pages:

    Performance thresholds are implementation evidence, not API promises. Passing a pinned finite corpus does not imply support for every operation or every real input.

    #Development

    Run the fast pull-request gate:

    just pr 8

    Useful focused commands:

    just fmt just docs just gate binary 8 just gate decimal 8 just gate decimal_gda 8 just gate interval 8 just bench bin-float --target native just bench auto-tune --target native

    Use the parameterized conformance entry point for smoke fixtures, plans, pinned corpora, targets, and phases:

    just conformance smoke binary just conformance run decimal --run-target native --run-target wasm just conformance run interval --phase trigonometric --strict-supported

    Operational corpus details live under testdata/bin_float, testdata/decimal, and testdata/interval.

    Before release, run the complete gate:

    just ci 8

    See CONTRIBUTING for contribution rules and Documentation Standard for localization/API snapshot requirements.

    #License

    Apache-2.0. See LICENSE.