www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2812] New: sqrt(2.0) is about -2.7341e-53

reply d-bugmail puremagic.com writes:
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


-- 
Apr 06 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2812


clugdbug yahoo.com.au changed:

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





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.


-- 
Apr 06 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2812






Yes.  Also, this seems to happen only for sqrt(double) not sqrt(float) or
sqrt(real).


-- 
Apr 06 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2812






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.


-- 
Apr 07 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2812


bugzilla digitalmars.com changed:

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





Fixed dmd 2.028


-- 
Apr 07 2009