Thread overview
[Issue 2812] New: sqrt(2.0) is about -2.7341e-53
Apr 06, 2009
d-bugmail
Apr 06, 2009
d-bugmail
Apr 06, 2009
d-bugmail
Apr 07, 2009
d-bugmail
Apr 08, 2009
d-bugmail
April 06, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2812

           Summary: sqrt(2.0) is about -2.7341e-53
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: andrei@metalanguage.com


import std.math, std.stdio;

void main()
{
    double x = sqrt(2.0);
    writeln(x);
}

prints

-2.7341e-53


-- 

April 06, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2812


clugdbug@yahoo.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |regression




------- Comment #1 from clugdbug@yahoo.com.au  2009-04-06 14:15 -------
Confirmed. Crucial information missing: on Windows at least, this is only with -O.

dmd -run bug.d
1.41421

dmd -run -O bug.d
-2.7341e-53

I'm raising this to regression.


-- 

April 06, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2812





------- Comment #2 from dsimcha@yahoo.com  2009-04-06 14:19 -------
Yes.  Also, this seems to happen only for sqrt(double) not sqrt(float) or
sqrt(real).


-- 

April 07, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2812





------- Comment #3 from clugdbug@yahoo.com.au  2009-04-07 02:08 -------
Not so.
float x = sqrt(2.0f);

is also wrong.
It only affects compile-time constants:
double y = 2.0;
double x = sqrt(y);
works correctly.


-- 

April 08, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2812


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #4 from bugzilla@digitalmars.com  2009-04-08 00:26 -------
Fixed dmd 2.028


--