[Issue 9297] Formatting of floating point values in std.format truncates reals to double

2021-04-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9297

Dlang Bot  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Dlang Bot  ---
dlang/phobos pull request #7951 "std.format: Replace snprintf for x87-reals"
was merged into master:

- 6fb98242e0f8d0b3532a9c63802453d44475070d by berni44:
  Fix Issue 9297 - Formatting of floating point values in std.format truncates
reals to double

https://github.com/dlang/phobos/pull/7951

--


[Issue 9297] Formatting of floating point values in std.format truncates reals to double

2021-04-11 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9297

Dlang Bot  changed:

   What|Removed |Added

   Keywords||pull

--- Comment #5 from Dlang Bot  ---
@berni44 created dlang/phobos pull request #7951 "std.format: Replace snprintf
for x87-reals" fixing this issue:

- Fix Issue 9297 - Formatting of floating point values in std.format truncates
reals to double

https://github.com/dlang/phobos/pull/7951

--


[Issue 9297] Formatting of floating point values in std.format truncates reals to double

2021-03-28 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9297

Berni44  changed:

   What|Removed |Added

 CC||ru...@rumbu.ro

--- Comment #4 from Berni44  ---
*** Issue 18326 has been marked as a duplicate of this issue. ***

--


[Issue 9297] Formatting of floating point values in std.format truncates reals to double

2021-02-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9297

Walter Bright  changed:

   What|Removed |Added

   See Also||https://issues.dlang.org/sh
   ||ow_bug.cgi?id=3248

--


[Issue 9297] Formatting of floating point values in std.format truncates reals to double

2018-03-07 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9297

Steven Schveighoffer  changed:

   What|Removed |Added

 CC||gambl...@gmail.com

--- Comment #3 from Steven Schveighoffer  ---
*** Issue 18570 has been marked as a duplicate of this issue. ***

--


[Issue 9297] Formatting of floating point values in std.format truncates reals to double

2013-09-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9297


Doug Nickerson tachyon...@gmail.com changed:

   What|Removed |Added

 CC||tachyon...@gmail.com


--- Comment #2 from Doug Nickerson tachyon...@gmail.com 2013-09-15 02:40:20 
PDT ---
Using DMD 2.063.2 on Win7 64-bit it doesn't appear to be casting to double when
compiling with the -m64 flag.  When using the s f or a format characters
and a real value I get 0 in the output.  I can manually cast to double and it
works fine (truncating though I presume).

Interestingly, when I remove the -m64 option it works for reals and double.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9297] Formatting of floating point values in std.format truncates reals to double

2013-02-26 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9297


hst...@quickfur.ath.cx changed:

   What|Removed |Added

 CC||hst...@quickfur.ath.cx


--- Comment #1 from hst...@quickfur.ath.cx 2013-02-26 16:56:01 PST ---
Does gcc/g++ support 80-bit floats? I made a little test program in a Linux
environment, and it seems that in spite of the cast, some extra precision is
still getting through:

import std.stdio;

void main() {
// Stuff with way too many digits than the types can handle, to see how
// far they get.
enum float phi_f = 1.6180339887_4989484820_4586834365f;
enum double phi_d = 1.6180339887_4989484820_4586834365;
enum real phi_r = 1.6180339887_4989484820_4586834365L;

// The exact digits, taken from:
//
//
http://fabulousfibonacci.com/portal/index.php?option=com_contentview=articleid=7Itemid=17
//
// (NOTE: the last digit is actually 6 if we round up the next digit
// instead of truncating. But built-in types won't even come close to
// that point).
string phi_s = 1.618033988749894848204586834365;

writeln(float.dig);
writeln(double.dig);
writeln(real.dig);

writefln(%.25f, phi_f);
writefln(%.25f, phi_d);
writefln(%.25f, phi_r);
writefln(%s, phi_s);
}


Output:

$ ./test
6
15
18
1.6180340051651000976562500
1.6180339887498949025257389
1.6180339887498948482072100
1.618033988749894848204586834365
$

Notice that the third line, which is the formatting of real, shows up with more
matching digits than double. Could this be something to do with the way the
Linux C/C++ ABI works (IIRC some floats gets passed in the FPU registers where
they retain their 80-bit precision)?

I don't have a way to test this on VC, though.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---