help: double precision problem

Nathan Sidwell nathan@codesourcery.com
Wed Aug 21 15:40:00 GMT 2002


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



More information about the Gcc-bugs mailing list