Bug 18326 – Reals greater than double.max are printed as infinity
Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2018-01-29T22:42:05Z
Last change time
2021-03-28T10:26:10Z
Assigned to
No Owner
Creator
Răzvan Ștefănescu
Comments
Comment #0 by rumbu — 2018-01-29T22:42:05Z
And reals smaller than double.min_normal * double.epsilon are printed as 0.
real rmax = +0x1.fffffffffffffffep+16383L
real rdbl = double.max;
rdbl *= 2;
real rmin = real.min_normal;
writefln("%a %a %a", rmax, rdbl, rmin)
//outputs inf inf 0x0.0000000000000p+0
Probably because formatting functions in phobos use 64 bit snprintf from MS Runtime which doesn't support reals.
Related: https://issues.dlang.org/show_bug.cgi?id=9297
Comment #1 by tiberiulepadatu14 — 2019-03-11T10:27:23Z
(In reply to Răzvan Ștefănescu from comment #0)
> And reals smaller than double.min_normal * double.epsilon are printed as 0.
>
> real rmax = +0x1.fffffffffffffffep+16383L
> real rdbl = double.max;
> rdbl *= 2;
> real rmin = real.min_normal;
>
> writefln("%a %a %a", rmax, rdbl, rmin)
> //outputs inf inf 0x0.0000000000000p+0
>
> Probably because formatting functions in phobos use 64 bit snprintf from MS
> Runtime which doesn't support reals.
>
> Related: https://issues.dlang.org/show_bug.cgi?id=9297
On Ubuntu it outputs:
0xf.fffffffffffffffp+16380 0xf.ffffffffffff8p+1021 0x8p-16385.
Comment #2 by b2.temp — 2019-03-11T23:20:13Z
Yet another reason to use Grisu or a similar library and to drop the standard C library for float to string conversion. Something like a dozen of issues would be fixed...
Comment #3 by bugzilla — 2021-03-28T10:26:10Z
*** This issue has been marked as a duplicate of issue 9297 ***