Library / Numbers / Math / FloatFormat
FloatFormat
Shortest-round-trippable float -> decimal string.
Fields 20
uint32 LOG2_OF_5_MULTuint32 LOG2_OF_5_SHIFTint32 LOG2_POW5_MAX_Euint32 LOG10_OF_2_MULTuint32 LOG10_OF_2_SHIFTint32 LOG10_POW2_MAX_Euint32 LOG10_OF_5_MULTuint32 LOG10_OF_5_SHIFTint32 LOG10_POW5_MAX_Eint32 DOUBLE_MANTISSA_BITSint32 DOUBLE_EXPONENT_BITSint32 DOUBLE_BIASint32 FLOAT_MANTISSA_BITSint32 FLOAT_EXPONENT_BITSint32 FLOAT_BIASint32 DOUBLE_POW5_INV_BITCOUNTint32 DOUBLE_POW5_BITCOUNTint32 FLOAT_POW5_INV_BITCOUNTint32 FLOAT_POW5_BITCOUNTint32 POW5_TABLE_SIZEMethods 10
METHOD float64toDecimal(uint64 bits) RETURNS FloatingDecimal64reads
Render the IEEE-754 double whose raw bits are bits as its
shortest round-trippable decimal String.
METHOD floatingDecimalToString(FloatingDecimal64 fd, boolean isNegative) RETURNS Stringreads
Turn a FloatingDecimal64 carrier into its final String, per the Phase 4 format-policy (floatformat-ryu-plan.md): Python-style threshold (sciExp < -4 OR >= 16), compact exponent (no '+', no leading zero), no trailing '.0', sign of zero dropped, special-case spellings "NaN"/"infinity"/"-infinity". MIRRORED by floatingDecimalToBytes — the two MUST stay byte-identical.
METHOD formatF64(uint64 bits) RETURNS Stringreads
One-shot: bits → FloatingDecimal64 → String. Convenience wrapper that chains float64toDecimal + floatingDecimalToString, extracting the sign bit from the raw bits.
METHOD floatingDecimalToBytes(MUTABLE REFERENCE binary[] out, FloatingDecimal64 fd, boolean isNegative) RETURNS voidreads
MIRROR of floatingDecimalToString — appends the bytes to out.
METHOD appendF64Bits(MUTABLE REFERENCE binary[] out, uint64 bits) RETURNS voidreads
MIRROR of formatF64 — appends the bytes for the float whose raw
bits are bits.
METHOD appendF64(MUTABLE REFERENCE binary[] out, float64 v) RETURNS voidreads
appendF64Bits from a float64 value — the serializer's entry point.
METHOD decimalF64(float64 v) RETURNS uint64reads
The Ryu decomposition of a float64 value, without formatting: v == (isNegative ? -1 : 1) * mantissa * 10^exponent, the mantissa the shortest that round-trips. Specials keep float64toDecimal's sentinel exponents (0x7FFFFFFC..0x7FFFFFFF).
METHOD float32toDecimal(uint32 bits) RETURNS FloatingDecimal32reads
Render the IEEE-754 float whose raw bits are bits as its
shortest round-trippable decimal. Same structural shape as
float64toDecimal above — re-read its STEP 1..5 comments
for the algorithm narrative; this body only flags the f32
specifics (narrower mantissa, narrower magic constants,
32-bit arithmetic throughout).
METHOD floatingDecimal32ToString(FloatingDecimal32 fd, boolean isNegative) RETURNS Stringreads
f32 sibling of floatingDecimalToString — identical logic; only the carrier type differs (FloatingDecimal32 vs FloatingDecimal64, uint32 vs uint64 mantissa). The shared digit-walking helpers (appendDigits, appendMantissaWithPoint, appendChars) take uint64 — uint32 mantissas widen at the call site.
METHOD formatF32(uint32 bits) RETURNS Stringreads
One-shot: bits → FloatingDecimal32 → String.