GCC compile time division error
- by kartikmohta
Can someone explain this behaviour?
test.c:
#include <stdio.h>
int main(void)
{
printf("%d, %d\n", (int) (300.6000/0.05000), (int) (300.65000/0.05000));
printf("%f, %f\n", (300.6000/0.05000), (300.65000/0.05000));
return 0;
}
$ gcc test.c
$ ./a.out
6012, 6012
6012.000000, 6013.000000
I checked the assembly code and it puts both the arguments of the first printf as 6012, so it seems to be a compile time bug.