gcc 4.0.3 double math/conversion error
Bug #128732 reported by
Ben Bridgwater
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-defaults (Ubuntu) |
Fix Released
|
Undecided
|
Matthias Klose |
Bug Description
Binary package hint: gcc
Running gcc (4.0.3) from Ubuntu 6.10 on a Pentium 4:
double d = 10.1;
int i = (int) (d * 10); // = 100
double t = d * 10;
int j = (int) t; // = 101
I would expect to get the same result (whatever it may be) in both cases.
To reproduce:
#include <stdio.h>
int main()
{
float f = 10.1;
double d = 10.1;
double t;
printf("%i %i %i\n", (int) (f * 10), (int) (d * 10), (int) (t = (d * 10)));
// gcc 4.0.3 (Ubuntu 6.10) output is: 101 100 101
}
gcc test.c
a.out
To post a comment you must log in.
fixed in edgy and newer releases; (gcc-4.1 and gcc-4.2)