[Issue 23200] New: sqrt cast to long and ulong differ
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jun 20 17:29:40 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23200
Issue ID: 23200
Summary: sqrt cast to long and ulong differ
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: kdevel at vogtner.de
unittest {
import std.math;
double d = 9007199515875288.;
auto r1 = cast (ulong) sqrt (d);
auto r2 = cast (long) sqrt (d);
assert (r1 == r2);
}
$ dmd -checkaction=context -unittest -main -run sub.d
sub.d(6): [unittest] 94906266 != 94906267
1/1 modules FAILED unittests
The expected value is 94906267:
$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
scale=17
sqrt(9007199515875288)
94906266.99999999473164401
For ASM code generated cf.
http://forum.dlang.org/post/qsjkksrkosylhqsohbvk@forum.dlang.org
--
More information about the Digitalmars-d-bugs
mailing list