[Issue 7376] New: floating point bug
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Fri Jan 27 00:29:08 PST 2012
    
    
  
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: nobody at puremagic.com
        ReportedBy: iteronvexor at gmail.com
--- Comment #0 from iteronvexor at 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: -------
    
    
More information about the Digitalmars-d-bugs
mailing list