This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: help: double precision problem


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]