This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Floating point computation "non-bug"
- From: Andreas Schwab <schwab at suse dot de>
- To: Dave Elcock <dave at sias dot com>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 11 Apr 2003 16:40:06 +0200
- Subject: Re: Floating point computation "non-bug"
- References: <3E96BA92.60003@sias.com>
Dave Elcock <dave at sias dot 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 at suse dot 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."