Mail Archives: djgpp/1996/12/01/19:28:35
> > Getting 112 is well within the C standard. If your program does
> > not work in this situation then you have a bug.
> The original response seems to be accurate. atof("1.13")*100 gives you
> 112.9..., which a printf call will nicely round to 1.13 for you. However,
> it is still less than 113 -- casting it to an int will round down, giving
> you 112. Unfortunate, but a limitation of floating point calculations.
> I just checked this on my Pentium Pro 200 which runs gcc 2.7.2 under Linux,
> and got the same result.
> > Floating point numbers are not exactly represented; you will see
> > rounding errors.
> That's the problem exactly.
Eli, can this go in the FAQ??? The reason being that I think all this
mail has just solved one of my problems I am having at the moment. Good
timing too, I nearly threw the computer out the window last night!!! :)
Leathal.
- Raw text -