http://d.puremagic.com/issues/show_bug.cgi?id=7376
Summary: floating point bug Product: D Version: D2 Platform: x86_64 OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: iteronve...@gmail.com --- Comment #0 from iteronve...@gmail.com 2012-01-27 00:29:06 PST --- As discussed in this thread: http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D.learn&artnum=31864 Shorter version of the bug: import std.stdio; void calculate1(float a, float b) { float s1 = 1.0f - a; float s2 = a * b; writeln(s2); writeln(a * b); } void calculate2(float a, float b) { float s1 = 1.0 - a; float s2 = a * b; writeln(s2); writeln(a * b); } void calculate3(double a, double b) { double s1 = 1.0 - a; double s2 = a * b; writeln(s2); writeln(a * b); } int main() { writeln("calculate1:"); calculate1(0.75f,2.0f); writeln("calculate2:"); calculate2(0.75f,2.0f); writeln("calculate3:"); calculate3(0.75f,2.0f); return 0; } ------------------------------------------------- + The complete output ------------------------------------------------- calculate1: 1.5 1.5 calculate2: 0 1.5 calculate3: 1.5 1.5 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------