feat(std/binary): read and write floats through bits() and ofBits() #447
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/349-binary-floats-via-bits"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #349
What
ByteReader.float32()answersFloat32,float64()keepsFloat64; both are theofBitsof the unsigned word read, so everynanpayload survives.ByteWriter.float32takes aFloat32,float64writesbits().std/binary/src/number.trblosesfloat32Pattern,float32OfPattern,float64Pattern,float64OfPatternand their helpers. The one user outside the package,roundedToFloat32incompiler/src/ir/constant.trb, narrows withFloat32.tryFrom(an infinity of the value's sign where it fails, as before).The amendments in the decision comment on #349 apply: the caller handles the
NumberRangeErrorof the narrowing (BINARY.md decision 3 says so), no wrapper in the package.reader.test.trb/writer.test.trbmoved toFloat32; new tests fornanpayloads (7fc00001,7f800001,ffc12345,7ff0000000000001,fff8dead0000beef, ...) in both byte orders; the narrowing failure.benchmarks/binary-float.trb(1Mfloat64()), run by the newtools/float-cost.shat the end of tier B for the merge base and each commit of the branch (same pattern astools/buffer-cost.sh; a measurement, not a gate). Numbers below.docs/standard-library/binary.mdand the regenerated page inskills/(patched by hand, notorbin the worker: CI'sdocs skill --checkconfirms).Seed
No new native, no syntax change. Second commit of the two-commit rule: the published seed
40164061bd10knows slices 1 and 2; CI bootstraps from it, so the bootstrap fixpoint in CI confirms the compiler's own use ofFloat32.tryFrom/Float64.from.Test
Forge CI only (no local bootstrap or gates). Result: see below.
c28d8e28d127a93b0372bits()/ofBits(_),float32()answers aFloat32#349CI red on
27a93b0:ci / tier A (linux-x64)failed after 24m31s;ci / gatesfailed after 0s (follows from tier A). Bootstrap, tier B, cross-host C emission, pdisc and the other checks are green. I could not read the tier A job log with my token, so the cause is not seen. Please check the log and push a fix; the review stays pending and runs again on the next CI result.Tier A was red on
27a93b0because of two gates:format --check(reader.trb, writer.test.trb) anddoc --check([ByteWriter.float32]/[ByteWriter.float64]links in reader.trb do not resolve, the reader does not import ByteWriter). Fixed inf1220f0: formatted withtorb format(the compiler artifact of run 1548) and named the writer methods in code spans instead of links. No behaviour change.Approved at
f1220f0(checklist):Non-blocking: