www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23200] New: sqrt cast to long and ulong differ


          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 puremagic.com
          Reporter: kdevel 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'. 

For ASM code generated cf.
http://forum.dlang.org/post/qsjkksrkosylhqsohbvk forum.dlang.org

Jun 20 2022