Floating point computation "non-bug"
Andreas Schwab
schwab@suse.de
Fri Apr 11 14:40:00 GMT 2003
Dave Elcock <dave@sias.com> writes:
|> Simply compiling with 'gcc test.c' and then running './a.out 2.3' gives
|> the following output:
|>
|> f1 2.300000
|> f2 23.000000
|> (int)f2 23
|> (int)(f1*10.0) 22
|>
|>
|> I can't see how such a simple example should be affected by floating point
|> precision.
Of course it can. 2.3 cannot be represented in base-2 floating point, so
what you have in f1 is not 2.3, but something close.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
More information about the Gcc-bugs
mailing list