about float error
kz 2002-08-08 05:47:28 I recently wrote a C code in VC both Debug and Release:
// An error!!!!!!!!!!!!!!!!!
float a = 0.005f;//error
int b = (int)(a * 1000000);
printf("%f, %d", a * 1000000, (int)(a * 1000000));// result: 4999.99988, 4999
as you see, I get an error result 4999.99988, 4999.
I have analysized it with unassembling.
In "error" line, I found that VC stores an error value 4999.999..8 to a
How to solve it?