Float conformance and limits

The contract separates exact integer encodings from portable numeric observations. Raw tests cover every classification, signed zero, exponent boundaries, NaN quiet bits, both signs, payload width limits and signaling-zero rejection. Rounding tests cover all five IEEE 754-2019 §5.9 directions, positive and negative ties, the predecessor of 0.5, negative zero, large integral values and infinities. Numeric tests use x != x for NaN and compare canonical integer output, never input NaN metadata.

Integer conversion tests are table driven. For each binary format a generated table lists the exact rounded integer of every input in each of the five directions (computed offline with fractions.Fraction, or marked NaN, at least 2^64 or at most -2^64). The test converts every input with all sixteen functions in the checked-presence, checked-value and saturating modes, in all five directions through the _with forms and once through the default functions, and compares each result with the table. The inputs include +0 and -0, ±0.5 and the other eighths below 9, halfway and quarter points next to every power of two 2^j for j = 0..69, the sweep 2^k and its neighbors one ulp away, the neighborhoods of ±2^31, 2^32, ±2^63 and 2^64 with fractional parts 0, 1/8, 1/4, 1/2 and 3/4, infinities, quiet and signaling NaNs with payloads, the smallest subnormal and the largest finite values, and 64 seeded random encodings. The default functions truncate; changing the default direction of any of them to TowardPositive fails the test (checked by mutation). For Int64 and UInt64 converted to binary32 and binary64, the table covers 2^k and its neighbors for k = 0..63, halfway and nearby remainders for 24-bit and 53-bit significands, 2^64 - 1, values near 2^64 - 2^39, and 2^53 + 2^29 + 1, where rounding through binary64 first gives the wrong binary32 result.

Ordering tests cover both argument orders for minimum/maximum, signed-zero selection, raw totalOrder across signed qNaN/sNaN payloads, portable NaN canonicalization, and array and mutable-view sorting. The generated integer-key oracle compares all pairs in a boundary sample for both binary formats.

Four-backend debug/release checks and exact transcript comparison follow the CI contract. Local results cannot establish Linux GCC behavior; CI must confirm that job. Tests are regression evidence, not a proof of all IEEE 754 behavior. No Lean/mathlib formal proof is supplied.

Stable hashing, formatting, bigint and libm remain separate issues; the exception flags of the operations of this package are described under “Exception flags” in the API page, and the host arithmetic operators have none until issue #64. Canonicalization is an application representation policy; it is not a promise to preserve floating-point payloads across a host round trip.

Clause traceability

IEEE Std 754-2019 for the host binary64 (Double) and binary32 (Float) types, through Luna-Flow/luna-utils/float and Luna-Flow/luna-utils/float/binary32, which expose the same names. Status is conforming when the operation exists and the cited evidence exercises it, partial when part of the clause is missing or the evidence is thin (the cell says which), not implemented and not applicable otherwise. Level is required for clauses the standard states with “shall” and recommended for those it states with “should”. Evidence names a test file or a tool in the repository. The roadmap that orders the gaps is issue #50.

ClauseLevelAPIEvidenceStatus
§3.4 binary32 and binary64 interchange encodingsrequiredclassify_bits, is_nan_bits, is_finite_bits, canonicalize_nan_bits, get_payload_bitsfixed corpus (testdata/float_oracles.json); the randomized audit (tools/random_audit.py) families classify, canonconforming
§4.3 rounding-direction attributesrequiredRoundingDirection (five directions) as an explicit argument of every operation of this package that roundssrc/float/bits_wbtest.mbt; the randomized audit (tools/random_audit.py) families round, convert, fma, scaleb, narrowpartial: the host operators + - * / and sqrt have only ties to even; #64
§5.3.1 addition, subtraction, multiplication, division, squareRootrequiredhost operators and sqrt (roundTiesToEven only)contraction probe (testdata/oracles.json); the randomized audit (tools/random_audit.py) family arithpartial: no directed rounding and no flags; #64
§5.3.1 fusedMultiplyAddrequiredfma_bits_flags, fma_bits_with, fma_bits, fma_with, fma (and the float/binary32 versions)src/float/fma_wbtest.mbt; the randomized audit (tools/random_audit.py) families fma, fma_flagsconforming
§5.3.1 remainderrequiredremainder_bits_flags, remainder_bits, remaindersrc/float/operations_wbtest.mbt; the randomized audit (tools/random_audit.py) families remainder, remainder_flagsconforming
§5.3.1 nextUp, nextDownrequirednext_up_bits_flags, next_down_bits_flags, next_up_bits, next_down_bits, next_up, next_downsrc/float/operations_wbtest.mbt; the randomized audit (tools/random_audit.py) families next, next_flagsconforming
§5.3.3 scaleB, logBrequiredscaleb_bits_flags, scaleb_bits_with, scaleb_bits, scaleb_with, scaleb, logb_bits_flags, logb_bits, logb_flags, logbsrc/float/operations_wbtest.mbt; the randomized audit (tools/random_audit.py) families scaleb, logb, scaleb_flags, logb_flagsconforming
§5.9 roundToIntegral (five directions)requiredround_to_integral, round_ties_even, round_ties_away, round_toward_zero, round_toward_positive, round_toward_negativesrc/float/bits_wbtest.mbt; the randomized audit (tools/random_audit.py) family roundconforming; no invalid or inexact report
§5.9 roundToIntegralExactrequiredround_to_integral_bits_flags (with exact=true)the randomized audit (tools/random_audit.py) family round_flagsconforming
§5.4.1, §5.8 convertToIntegerrequiredto_int_checked, to_int64_checked, to_uint_checked, to_uint64_checked, the *_saturating and *_with forms, and to_int_flags, to_int64_flags, to_uint_flags, to_uint64_flags (with exact=true for the Exact variants)fixed tables (testdata/float_oracles.json); the randomized audit (tools/random_audit.py) families convert, convert_flagsconforming
§5.4.1 convertFromIntrequiredint64_to_float, uint64_to_float (binary32); host conversions for the other pairscompiler matrix (tools/compiler_matrix.py); the randomized audit (tools/random_audit.py) families conv_i32, conv_u32, conv_i64, conv_u64, conv_i64_f32, conv_u64_f32, int_to_f32partial: this package provides only the two binary32 conversions; the host conversions match the model on every backend except Int64 and UInt64 to Float on js, where core follows the backend (see the known-issues list)
§5.4.2 convertFormatrequiredto_binary32_bits_flags, to_binary32_bits_with, to_binary32_bits, to_binary32_with, to_binary32, to_binary64_bits_flags, to_binary64_bits, to_binary64src/float/convert_format_wbtest.mbt; the randomized audit (tools/random_audit.py) families narrow, widen, narrow_flags, widen_flagsconforming; the host Float::from_double and Float::to_double also match the model on every backend
§5.5 copy, negate, abs, copySignrequiredcopy_sign_bits, negate_bits, abs_bits, portable_copy_sign, portable_negate, portable_abssrc/float/bits_wbtest.mbt; the randomized audit (tools/random_audit.py) family signconforming
§5.6, §5.11 comparison predicatesrequiredComparisonPredicate (the 22 predicates), Relation, relation, relation_bits, compare_predicate, compare_predicate_bits, predicate_outcomesrc/float/comparison_wbtest.mbt; the randomized audit (tools/random_audit.py) family compareconforming; invalid operation is returned as a Bool until exception flags exist (#29)
§5.7 class and sign predicatesrequiredclassify_bits, portable_classify, is_sign_minus_bits, is_zero_bits, is_subnormal_bits, is_signaling_bits, is_canonical_bits, is_infinite_bits, is_normal_bits, is_nan, is_infinite, is_normal, radixsrc/float/bits_wbtest.mbt; the randomized audit (tools/random_audit.py) family classifyconforming
§5.10 totalOrderrequiredtotal_order_bits, portable_total_order, sort_total_order, sort_total_order_viewfixed corpus; the randomized audit (tools/random_audit.py) families total_order, sortconforming
§5.10 totalOrderMagrequiredtotal_order_mag_bits, portable_total_order_magthe randomized audit (tools/random_audit.py) family extremaconforming
§5.12 decimal character conversionrequirednonenonenot implemented; #27
§5.12.3 hexadecimal character conversionrequirednonenonenot implemented; #27
§6.1–§6.3 infinities, NaNs and the sign bitrequiredraw-bit APIs keep NaN sign, signaling state and payload; numeric APIs map every NaN to one quiet NaNsrc/float/bits_wbtest.mbt; the randomized audit (tools/random_audit.py) family canonpartial: a numeric NaN cannot carry a payload on every backend (by design, documented)
§7.2–§7.6 exceptions and flagsrequiredFlags (invalid, divideByZero, overflow, underflow, inexact; tininess is detected after rounding) returned by the *_flags forms of fma, remainder, nextUp, nextDown, scaleB, logB, roundToIntegral(Exact), convertToInteger and convertFormat, and (value, invalid) of the comparison predicatesthe randomized audit (tools/random_audit.py) flags familiespartial: the host operators + - * / and sqrt raise no flags; #64
§8 alternate exception handlingrecommendednonenonenot implemented by design (flags are values, #29)
§9.2 recommended mathematical functionsrecommendednonenonenot implemented; #30
§9.3 dynamic mode operationsrecommendednone (rounding directions are explicit arguments)nonenot implemented by design
§9.4 reduction operationsrecommendednonenonenot implemented; #49
§9.5 augmented arithmeticrecommendednonenonenot implemented; #29 (error-free transformations)
§9.6 minimum and maximumrecommendedminimum, maximum, minimum_number, maximum_number, minimum_magnitude, maximum_magnitude, minimum_magnitude_number, maximum_magnitude_numbersrc/float/bits_wbtest.mbt; the randomized audit (tools/random_audit.py) family extremaconforming; a numeric value cannot report invalid operation for a signaling NaN
§9.7 NaN payload operationsrecommendedget_payload_bits, set_payload_bits, set_payload_signaling_bitssrc/float/bits_wbtest.mbt; the randomized audit (tools/random_audit.py) family payload_get, payload_setpartial: integer encoding adapters instead of getPayload and setPayload on floating-point values