write/1 prints whole-valued floats without a decimal point (non-ISO output) #32
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Summary
write/1renders a float with no fractional part as if it were an integer —dropping the
.0. The value's type is internally correct (it really is afloat), but the textual output is indistinguishable from the integer and would
not read back as a float, which violates ISO write semantics for floats.
Version
plgc 0.3.0.Reproduction
Given any program file
p.pl(e.g.p.):(The first line of each run is
write/1's own output, followed bynl; theX = …line is the binding display. Both show the same dropped.0, confirmingthis is
write/1itself and not only the CLI result formatter.)Expected (ISO)
A float must be written with a decimal point and at least one fractional digit,
so
write(2.0)→2.0andwrite(1024.0)→1024.0. The written form must readback as a float (round-trip).
Actual
write(2.0)emits2;write(1024.0)emits1024. Non-whole floats arecorrect (
write(3.5)→3.5), so the defect is specific to whole-valued floats.Value semantics are otherwise correct
So this is purely an output-formatting compliance bug sitting on top of
correct value/type semantics.
Found while authoring the loglings
curriculum.
#34