floating
Luna-Flow/floating is arbitrary-precision floating-point arithmetic for
MoonBit: binary values with IEEE 754 semantics at any precision, IEEE 754 and
General Decimal Arithmetic decimals, and certified interval (ball) arithmetic
following IEEE 1788. Precision, rounding, exponent range, special values,
status flags, traps and enclosures are explicit values in every API rather
than hidden global state. This manual documents the current branch; the
current release is 0.8.0.
Install
moon add Luna-Flow/floating@0.8.0
Then import the packages you need in your moon.pkg, for example
"Luna-Flow/floating/bin_float". The module needs the MoonBit toolchain 0.10
or later (moonc ≥ 0.10). It depends on Luna-Flow/arithmetic (rounding
modes, contexts, checked and contextual traits) and Luna-Flow/luna-generic
(algebraic traits); add Luna-Flow/arithmetic yourself when you name its
types. Getting started walks through the first
program.
Guides
| Guide | Read it for |
|---|---|
| Getting started | choosing a package, installing, first values, contexts and failure models |
| Numeric semantics | the shared vocabulary: exact value and rounded result, rounding functions, ulp and unit roundoff, flags, quantum, signed zero, NaN, enclosures |
| Architecture | package layers, the numeric core pipeline, certified elementary functions, invariants |
| Verification | the gates, the published conformance claims and how to reproduce them |
| Performance audit | proofs and evidence for the optimized arithmetic paths |
| Repository conventions | documentation rules and the review checklist |
Package map
Each package has a tutorial (how to use it), an API reference (what you can call) and a design page (why it works this way). The four numerical cores also have conformance and performance pages.
Numerical cores
| Package | Purpose | Pages |
|---|---|---|
bin_float | arbitrary-precision binary floating point, IEEE 754 binary operations and binary16/32/64/128 interchange | tutorial · API · design · conformance · performance |
decimal | IEEE 754 arbitrary-precision decimal with per-operation flags and DPD/BID interchange | tutorial · API · design · conformance · performance |
decimal_gda | General Decimal Arithmetic with sticky status and traps | tutorial · API · design · conformance · performance |
ball_float | outward-rounded bare and decorated intervals (IEEE 1788) | tutorial · API · design · conformance · performance |
Composition and shared vocabulary
| Package | Purpose | Pages |
|---|---|---|
def | Sign, PartialOrder, the Floating trait, predicates and re-exported arithmetic types | tutorial · API · design |
bin_float_checked | binary pipelines that stop at the first error | tutorial · API · design |
decimal_checked | IEEE decimal pipelines that accumulate flags | tutorial · API · design |
decimal_gda_checked | GDA pipelines that thread status and stop at traps | tutorial · API · design |
ball_float_checked | interval pipelines that stop at the first error | tutorial · API · design |
semantic | exact, representation-independent projection for cross-package comparison | tutorial · API · design |
Expressions and corpus frontends
| Package | Purpose | Pages |
|---|---|---|
numeric_expr | host-independent numeric expression syntax and evaluation | tutorial · API · design |
frontend/gda_expr | parse and execute GDA .decTest files | tutorial · API · design |
frontend/itl_expr | parse and execute ITF1788 interval test rows | tutorial · API · design |
frontend/mpfr_expr | parse and execute pinned MPFR witnesses | tutorial · API · design |
frontend/testfloat_expr | parse and execute Berkeley TestFloat vectors | tutorial · API · design |
Conformance command line
| Package | Purpose | Pages |
|---|---|---|
cli | native dispatcher for the four conformance backends | tutorial · API · design |
cli/gda_expr_cli | file and output adapter for .decTest runs | tutorial · API · design |
cli/itl_expr_cli | file and JSON adapter for ITF1788 runs | tutorial · API · design |
cli/mpfr_expr_cli | command adapter for MPFR witness runs | tutorial · API · design |
cli/testfloat_expr_cli | command adapter for TestFloat runs | tutorial · API · design |
Infrastructure and evidence
| Package | Purpose | Pages |
|---|---|---|
internal | shared exact-rational, big-integer, parsing, normalization and rounding helpers | tutorial · API · design |
internal/conformance | source locations, deterministic shards, case dispositions and summaries | tutorial · API · design |
internal/runner_cli | shared CLI options, files, diagnostics and JSON | tutorial · API · design |
consistency | white-box cross-package laws and API audits | tutorial · API · design |
doc_examples | executable documentation examples run by just docs | tutorial · API · design |
bench | shared Maremark benchmark infrastructure | tutorial · API · design |
bench/bin_float | binary arithmetic and elementary-function benchmarks | tutorial · API · design |
bench/decimal | IEEE decimal benchmarks | tutorial · API · design |
bench/decimal_gda | GDA decimal benchmarks | tutorial · API · design |
bench/ball_float | interval arithmetic benchmarks | tutorial · API · design |
The application surface is the numerical cores, def and the checked
wrappers; semantic and numeric_expr are provisional integration surfaces.
The other packages publish interfaces because repository tools compose them,
and their design pages state narrower stability promises.
Reading paths
- New to the library. Read getting started, then
the tutorial of the package you chose, for example the
bin_floattutorial or thedecimaltutorial. Keep numeric semantics open for the vocabulary. - Using it in an application or library. Read numeric semantics once, then work from the API pages of your packages. Before you rely on a standard behaviour, check the matching conformance page; for pipelines, read the tutorial of the checked wrapper.
- Contributing. Read architecture, verification and the repository conventions, then the design page of the package you change. Changes to an optimized path also need the performance audit and the package’s performance page.
Evidence snapshot
- The pinned GDA
officialcorpus passes 64,986/64,986 legal executable scalar rows, andofficial0passes 16,124/16,124. The 141#placeholder or non-scalar rows are diagnostic exclusions. - The binary TestFloat level-1 matrix passes 254,227,872 vectors across binary16/32/64/128, including fused multiply-add, remainder, round to integral, integer conversions and the comparison predicates, plus pinned MPFR square-root and elementary-function witnesses.
- The strict ITF1788 aggregate passes 4,656/4,656 selected interval cases.
- The IEEE decimal gate covers decimal32/64/128 DPD and BID encodings, flags and arithmetic on four targets.
These finite results do not imply support for every operation, every future corpus revision or every real input. Read the conformance page of a package before turning a result into a compatibility claim.
Authority
pkg.generated.mbti defines what is public, and source and tests define
behaviour; if a page and the generated interface disagree, the interface wins.