Bug 2812 – sqrt(2.0) is about -2.7341e-53

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2009-04-06T14:09:00Z
Last change time
2015-06-09T05:14:56Z
Assigned to
bugzilla
Creator
andrei

Comments

Comment #0 by andrei — 2009-04-06T14:09:30Z
import std.math, std.stdio; void main() { double x = sqrt(2.0); writeln(x); } prints -2.7341e-53
Comment #1 by clugdbug — 2009-04-06T14:15:25Z
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.
Comment #2 by dsimcha — 2009-04-06T14:19:16Z
Yes. Also, this seems to happen only for sqrt(double) not sqrt(float) or sqrt(real).
Comment #3 by clugdbug — 2009-04-07T02:08:12Z
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.
Comment #4 by bugzilla — 2009-04-08T00:26:40Z
Fixed dmd 2.028