Bug 20536 – std.format: %a on reals is inconsistent with %a on float/double
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-01-26T17:06:00Z
Last change time
2021-04-12T07:25:31Z
Keywords
pull
Assigned to
berni44
Creator
berni44
Comments
Comment #0 by bugzilla — 2020-01-26T17:06:00Z
On my computer the format command below produces "0x8p-23" which is inconsitent with the results from float/double, where the first digit after "0x" is always a 1 (leaving aside corner cases). The test below should work independent of the type of real used.
void main()
{
import std.format : format;
real r = .00000095367431640625L;
assert(format("%a", r) == "0x1p-20"); // fails
}
Comment #1 by dlang-bot — 2021-04-11T10:17:45Z
@berni44 created dlang/phobos pull request #7951 "std.format: Replace snprintf for x87-reals" fixing this issue:
- Fix Issue 20536 - std.format: %a on reals is inconsistent with %a on float/double
https://github.com/dlang/phobos/pull/7951
Comment #2 by dlang-bot — 2021-04-12T07:25:31Z
dlang/phobos pull request #7951 "std.format: Replace snprintf for x87-reals" was merged into master:
- c9121a8c8930b06fca9d8ee6963b630b1cbae59e by berni44:
Fix Issue 20536 - std.format: %a on reals is inconsistent with %a on float/double
https://github.com/dlang/phobos/pull/7951