Simple question

Phil Dobbin phildobbin at gmail.com
Tue Apr 15 14:18:47 EDT 2014


Hi, all.

I've just started to learn Python (I'm reading Mark Lutz's 'Learning
Python' from O'Reilly) & I'm confused as to this part:

'>>> 0.1 + 0.1 + 0.1 - 0.3
5.55111.....'

Using 'import Decimal' you can get a much closer result i.e.
'Decimal('0.0')'

What I'm wondering is why the first calculation that arrives at
'5.55111...' is so far out?

Many thanks,

Cheers,

  Phil...

-- 
currently (ab)using
CentOS 6.5, Debian Squeeze & Wheezy, Fedora 19 & 20, OS X Snow Leopard,
RHEL 7, Ubuntu Precise & Saucy
GnuGPG Key : http://phildobbin.org/publickey.asc
Based in London, UK




More information about the Python-list mailing list