Arbitrary-precision binary, decimal, and ball arithmetic for MoonBit, with checked operations and explicit numeric semantics.
Dependencies
moon add Luna-Flow/floating@0.7.1import {
"Luna-Flow/floating/bin_float"
"Luna-Flow/floating/decimal"
"Luna-Flow/floating/decimal_gda"
"Luna-Flow/floating/ball_float"
}///|
test "floating 0.7.1 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")
}| Requirement | Package | Result model | Documentation |
|---|---|---|---|
| arbitrary-precision dyadic and IEEE binary interchange | bin_float | value or (value, BinaryFlags) | API · Tutorial · Design |
| IEEE decimal and DPD/BID interchange | decimal | value or (value, DecimalFlags) | API · Tutorial · Design |
| General Decimal Arithmetic status and traps | decimal_gda | GdaOutcome with defined result and next context | API · Tutorial · Design · Performance |
| certified real enclosure and IEEE 1788 decorations | ball_float | bare/decorated interval, optionally with BallFlags | API · Tutorial · Design · Performance |
| first-error binary pipeline | bin_float_checked | Result[BinFloat, ArithmeticError] wrapper | Tutorial |
| accumulated IEEE decimal pipeline | decimal_checked | value + latest/combined flags + optional certification error | Tutorial |
| sticky/trapping GDA pipeline | decimal_gda_checked | one threaded GdaOutcome | Tutorial |
| first-error interval pipeline | ball_float_checked | Result[BallFloat, ArithmeticError] wrapper | Tutorial |
| representation-independent observation | semantic | exact scalar/interval projection | API |
just pr 8just 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 nativejust conformance smoke binary
just conformance run decimal --run-target native --run-target wasm
just conformance run interval --phase trigonometric --strict-supportedjust ci 8Arbitrary-precision binary, decimal, and ball arithmetic for MoonBit, with checked operations and explicit numeric semantics.
Dependencies