// floatlit_test — float LITERAL fold correctly-rounded, migrated from // test/wcc/989_floatlit_run.c (#5-C4). The two stages once folded float // literals differently: cstage via strtod (correctly rounded), wwstage via a // pow-10 accumulation that was 1-2 ULP off on decimal fractions, overflowed its // i64 accumulator past 19 mantissa digits, and missed DBL_MIN/DBL_MAX by up to // 2 ULP (989 ratchet #59.10). The fix routes lexnum through strconv.stof64 (the // Hare-ported correctly-rounded decimal engine). // // Each row reads back a literal's IEEE bits via a *u64 reinterpret and asserts // the C-strtod-oracle bit pattern. The C driver ran (a) cstage build+run + (b) // w6c-vs-w6c_ww .s byte-id; here the cstage run is test-lang (T1) and byte-id is // test-lang-byteid (T2), so both dimensions survive. The overflow-reject leg // (1.7976931348623159e308, both stages must reject) is the fold-3 runww carrier // test/wcc/data/floatlit_overflow/case.ww. package floatlit_test; fn bits(v: f64) u64 = { let x: f64 = v; let p: *u64 = (&x): *u64; return *p; }; @test fn vectors() void = { assert(bits(1.0000000000000002) == 0x3FF0000000000001u64); assert(bits(9007199254740993.0) == 0x4340000000000000u64); assert(bits(1.2345e67) == 0x4DDD4E421712C0B7u64); assert(bits(0.1) == 0x3FB999999999999Au64); assert(bits(1.1) == 0x3FF199999999999Au64); assert(bits(123456789012345678901234567890.0) == 0x45F8EE90FF6C373Eu64); assert(bits(2.2250738585072014e-308) == 0x0010000000000000u64); assert(bits(0.3) == 0x3FD3333333333333u64); assert(bits(3.141592653589793) == 0x400921FB54442D18u64); assert(bits(1.7976931348623157e308) == 0x7FEFFFFFFFFFFFFFu64); assert(bits(1.7976931348623158e308) == 0x7FEFFFFFFFFFFFFFu64); assert(bits(7.2057594037927933e16) == 0x4370000000000000u64); assert(bits(1000000000000000000000.0) == 0x444B1AE4D6E2EF50u64); assert(bits(1_000.5) == 0x408F440000000000u64); assert(bits(1.00000000000000011102230246251565404236316680908203125) == 0x3FF0000000000000u64); assert(bits(1.00000000000000011102230246251565404236316680908203126) == 0x3FF0000000000001u64); assert(bits(4503599627370497.5) == 0x4330000000000002u64); assert(bits(0.5) == 0x3FE0000000000000u64); assert(bits(1.0e308) == 0x7FE1CCF385EBC8A0u64); assert(bits(2.225073858507202e-308) == 0x0010000000000001u64); };