Bug 18570 – exp function does not work correctly for real in 64bit Windows

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2018-03-07T17:08:44Z
Last change time
2018-03-07T19:28:10Z
Assigned to
No Owner
Creator
Matthew Gamble

Comments

Comment #0 by gamblemj — 2018-03-07T17:08:44Z
exp(real x) does not work when compiled under 64bit but does work under x86. Others have confirmed this: https://forum.dlang.org/post/[email protected] below is a simple example. import std.stdio; import std.math; unittest { writefln("ln(largest double) = %s", log(double.max)); // 709.783 writefln("e^710 = %s", exp(710.0));// inf, makes sense perhaps writefln("ln(largest real) = %s", log(real.max)); // 11356.6 real t = 710.0; writefln("e^710 = %s", exp(t)); //inf in 64bit, 2.23399e+308 for 32bit }
Comment #1 by rumbu — 2018-03-07T19:05:34Z
The exp function works correctly. The problem is writefln calling snprintf from Microsoft stdlib which does not support reals. Real parameters are downcasted to double, that's why we obtain infinity. The same will happen on 32-bit if compiled with -mscoff32. Problem: https://github.com/dlang/phobos/blob/master/std/format.d#L2532
Comment #2 by rumbu — 2018-03-07T19:09:13Z
Comment #3 by gamblemj — 2018-03-07T19:23:51Z
Very helpful Răzvan. Thanks. I hope that bug can be fixed in the future.
Comment #4 by schveiguy — 2018-03-07T19:28:10Z
Thanks, seems like this is a duplicate then. *** This issue has been marked as a duplicate of issue 9297 ***