Bug 19878 – Some NaNs are printed as -nan

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-05-16T01:24:13Z
Last change time
2019-10-24T15:50:39Z
Keywords
bootcamp
Assigned to
No Owner
Creator
Andrei Alexandrescu

Comments

Comment #0 by andrei — 2019-05-16T01:24:13Z
Test code: void main() { import std.stdio; union X { int x; float y; } X x; x.x = -1; writeln(x.y); } This should print "nan" but prints "-nan".
Comment #1 by iamthewilsonator — 2019-10-19T21:23:19Z
This is a phobos bug, not a dmd one.
Comment #2 by dlang-bugzilla — 2019-10-20T15:10:32Z
////////// test.c ////////// #include <stdio.h> union X { int x; float y; }; int main() { union X x; x.x = -1; printf("%f\n", x.y); return 0; } //////////////////////////// This also prints -nan. What's the bug?
Comment #3 by bugzilla — 2019-10-20T17:26:49Z
Maybe it's no bug? IMHO the answer depends if D distinguishes between -nan and nan or not.
Comment #4 by rschadek — 2019-10-22T09:24:02Z
Comment #5 by bugzilla — 2019-10-24T15:50:39Z
According to the discussion of PR 7222, this is not considered a bug.