Data type sequence error:Dictionary

Brian van den Broek bvande at po-box.mcgill.ca
Wed Jul 28 10:36:04 CEST 2004


Derek Thomson said unto the world upon 28/07/2004 04:27:

> On Wed, 28 Jul 2004 15:56:00 +0800, BlackWhite <live1024 at hotmail.com> wrote:
> 
>>[3.1400..01,42,9]            //Why 3.140000000000000001 should not have 1 in
>>the end
>>
>>Why this happened?
> 
> 
> I just realized you were asking two questions there ...
> 
> The reason 3.14 didn't get returned as exactly 3.14 is that, in
> Python, real numbers are represented in "floating point." This is a
> particular scheme for storing numbers in computers that, while
> allowing the representation of very large and very small real numbers
> and at the same time staying within a strict size, sacrifices the
> ability to exactly represent all possible numbers. 3.14 is one of
> those numbers.
> 
> Wikipedia has an article on floating point numbers here:
> http://en.wikipedia.org/wiki/Floating_point
> 
> If you can't live with this restriction, you may have to use some
> other representation. I'm not sure which (if any) are available with
> Python, so someone else will have to weigh in there.
> 
> dt.

Hi again,

I've not tried 2.4 alpha, but there's a relevant section in Kuchling's 
What's New in Python 2.4 -- 5 PEP 327: Decimal Data Type
<http://www.python.org/dev/doc/devel/whatsnew/node6.html>

Best,

Brian vdB




More information about the Python-list mailing list