Mail Archives: djgpp/1996/12/01/00:39:04
Morten Welinder wrote:
> 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.
--
Erik Max Francis | max AT alcyone DOT com
Alcyone Systems | http://www.alcyone.com/max/
San Jose, California | 37 20 07 N 121 53 38 W
&tSftDotIotE | R^4: the 4th R is respect
"But since when can wounded eyes see | If we weren't who we were"
- Raw text -