Library / System / Conversions / FloatParseResult
FloatParseResult
Fields 1
int32 MAX_DIGITSConstructors 1
INIT()Methods 13
MODIFY METHOD pushDigit64(uint32 d) RETURNS voidmodifies
Accumulate one decimal digit into the uint64 fast-path significand, flipping sig64Ovf the moment sig64·10+d would exceed uint64.
METHOD isValid() RETURNS booleanreads
Whether the last parse() produced a well-formed value (the FloatParse surface reads this to choose the success vs FAILURE arm).
METHOD charEqCI(char32 c, char32 lower) RETURNS booleanreads
ASCII case-insensitive char compare (lower is the lowercase letter).
METHOD isInfinityWord(REFERENCE String s, int64 start, int64 endp) RETURNS booleanreads
TRUE iff s[start, endp) spells "inf" or "infinity" (case-insensitive).
METHOD computeBitsN(int32 mantBits, int32 eMin, int32 biasAdd, int32 maxBiased, int32 signPos) RETURNS uint64reads
L4 — the exact float driver, generalized over target width. Produce the
correctly-rounded IEEE-754 bit pattern for the parsed (significand, exp10,
sign) via big-integer AlgorithmM: form V = sig·10^exp10 = N/D, scale to
[2^mantBits, 2^(mantBits+1)) tracking the binary exponent e2 (subnormal
floor at eMin), extract the mantissa by binary long-division, round-to-
nearest-even (with the truncated sticky bit), then handle rounding
overflow and the subnormal/normal/inf encodings. Parameters:
float64 → (52, -1074, 1075, 2047, 63) float32 → (23, -149, 150, 255, 31)
where biasAdd = mantBits + exponent-bias, maxBiased = 2^expBits − 1.
METHOD computeBits() RETURNS uint64reads
Correctly-rounded IEEE-754 binary64 / binary32 bit patterns (exact path).
METHOD computeBits32() RETURNS uint64reads
METHOD clingerEligible() RETURNS booleanreads
TRUE iff the Clinger fast path applies to the parsed value at float64.
METHOD eiselLemire64() RETURNS | uint64reads
Eisel-Lemire tier-2 fast path — value = sig64 · 10^exp10 with sig64 known exact (fits uint64). Returns the float64 MAGNITUDE bit pattern on a confidently-correct rounding, or FAILURE to fall back to the exact path. A faithful port of Rust dec2flt lemire.rs, validated in Python (0 mismatches over ~200k cases). It NEVER commits a wrong result — the only outcomes are the correctly-rounded value or a fall-back signal.
METHOD toFloat64() RETURNS float64reads
The parsed value as a real float64. Tiered: (L8) Clinger for the common exactly-representable case; then Eisel-Lemire for the wider fits-in-uint64 case; then the exact bignum computeBits() for everything else / EL fall-back.
METHOD clingerEligible32() RETURNS booleanreads
Clinger applies at float32 when sig ≤ 2^24 and |exp10| ≤ 10 (10^10 = 5^10· 2^10, 5^10 < 2^24, so it is an exact float32).
METHOD toFloat32() RETURNS float32reads
MODIFY METHOD parse(REFERENCE String s) RETURNS voidmodifies
Parse s into this result's fields. Sets valid = FALSE (and stops) on any
character outside the strict finite-number grammar or on non-consumption.