lib/strconv: f32tos Ryū shortest float→string (#106 fold-5b)
The f32 coda of Drew's strconv 5-fold plan — f64tos shipped in fold-5a (0e66073); this completes the plan. Re-lands the f32-exclusive Ryū path that fold-5a removed under the dead-code rule (it was #143-blocked): pow5fac32/pow5multiple32/pow2multiple32, mulshift32, mulpow5inv_divpow2/ mulpow5_divpow2, decf32, f32todecf32 (ftos_ryu.ha), and the f32tos driver (ftos.ha:448). Plus F32_POW5_*_BITCOUNT in ftos_data.ww. The f32 path REUSES the shared u64 core (mulshiftall64/u128mul/u128rshift/ log*) and f64computeinvpow5/f64computepow5 — and thus the f64 SPLIT2 tables — exactly as ftos_ryu.ha does; there are no separate f32 tables. Unblocked by #143 (aff7725): f32tos calls math.f32bits(n), passing an f32 arg, which now spills MOVSS (4B) in both stages. Verified: f32tos's arg push/pop is MOVSS, w6c vs w6c_ww 0-diff on the strconv-embedding combined.ww (w6c/wwdump/smoke regenerated). Dodges (cgen bugs still deferred, each cited at-site): decf32.exponent:i64 sidesteps the #169 narrow-second-field struct-return unpack (byte-id gate-confirmed, not an ABI guarantee); #168 div/mod local-bind on the two `%10` sites; *decimal pointer field reads (#170); [32]u8 buffer reuses f64tos's byte-id-clean band over Hare's [14] (#43). mulshift32's U32_MAX bound inlines the literal — ww's types.U32_MAX is package-private (#172). Test: ftostest.ww gains f32 vectors — the tcs G/void rows (shared f32/f64 shortest), the f32-exclusive tcsf32 extremes (1e-45 / 1.1754944e-38 / 3.4028235e38, full 24-bit mantissa), specials, a negative-normal, and 33554432 (the sole e2>=0/q<=9 runtime cover). make test 187/187 incl 908_ftos_run + 990-997 byte-id + combined_ww_fresh.
This commit is contained in:
@@ -25,12 +25,18 @@ package strconv;
|
||||
// power-of-five tables. Defined u8 (faithful); ftos.ww casts to u32/i32
|
||||
// at each use site (Hare promotes a u8 def inside mixed-width arithmetic;
|
||||
// ww is strict — explicit cast, project_int_machine_word_derived_limits).
|
||||
// The F32_POW5_*_BITCOUNT siblings (ftos_ryu.ha:162-163) land in fold-5b
|
||||
// (task #67) with their only consumer, f32todecf32 — omitted here to keep
|
||||
// this fold dead-code-free.
|
||||
def F64_POW5_INV_BITCOUNT: u8 = 125u8;
|
||||
def F64_POW5_BITCOUNT: u8 = 125u8;
|
||||
|
||||
// ref/hare/strconv/ftos_ryu.ha:162-163. The f32 split-table bit-counts,
|
||||
// derived from the f64 siblings (Hare: F64_..._BITCOUNT - 64). Consumed by
|
||||
// f32todecf32 (ftos.ww), landed in fold-5b (task #67) — the f32 path reuses
|
||||
// the f64 SPLIT2 tables (via f64computeinvpow5/f64computepow5), so no
|
||||
// separate F32 tables exist (matches ftos_ryu.ha). u8 like the f64 defs;
|
||||
// ftos.ww casts to u32/i32 at each use.
|
||||
def F32_POW5_INV_BITCOUNT: u8 = F64_POW5_INV_BITCOUNT - 64u8;
|
||||
def F32_POW5_BITCOUNT: u8 = F64_POW5_BITCOUNT - 64u8;
|
||||
|
||||
// ref/hare/strconv/ftos_ryu.ha:165-181.
|
||||
let F64_POW5_INV_SPLIT2: [15][2]u64 = [
|
||||
[1u64, 2305843009213693952u64],
|
||||
|
||||
Reference in New Issue
Block a user