This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: help: double precision problem
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: JDE <jdelfosse at free dot fr>
- Cc: gnu-gcc-bug at prep dot ai dot mit dot edu
- Date: Wed, 21 Aug 2002 23:40:04 +0100
- Subject: Re: help: double precision problem
- Organization: Codesourcery LLC
- References: <3d63f58f$0$566$626a54ce@news.free.fr>
JDE wrote:
> Below is a simple code that shows a double precision problem.
> ( We try to check that 1987654321.11 + 0.1 = 198765432.21 )
> I'm surprised to have such a problem with so few digits after the dot.
>
> Does anyone have an explanation ?
yes. 10 = 2*5, so any 2^-n is representable in base 10 in a
finite number of places. However, because of that 5, the converse
is not true. 10^-n is not representable in base 2 with a finite
number of places.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org