Issue427036
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2001-05-24 19:40 by darkmo0d, last changed 2022-04-10 16:04 by admin. This issue is now closed.
Messages (4) | |||
---|---|---|---|
msg4857 - (view) | Author: David Waggle (darkmo0d) | Date: 2001-05-24 19:40 | |
=darkmo0d=[14:52:28]darkmo0d<$> python -c 'a=[66.6] ;print a' [66.599999999999994] should this occur? seems like it could cause a serious problem, provided this is not specific to my machine. Which is: x86 Linux Kernel 2.4.5-pre1 Python 2.1 Celeron 433mHz with 256MB SDRAM |
|||
msg4858 - (view) | Author: Tim Peters (tim.peters) * | Date: 2001-05-24 20:00 | |
Logged In: YES user_id=31435 This is not a bug. Binary floating point cannot represent decimal fractions exactly, so some rounding always occurs (even in Python 1.5.2). What changed is that Python 2.0 shows more precision than before in certain circumstances (repr() and the interactive prompt). You can use str() or print to get the old, rounded output: >>> print 0.1+0.1 0.2 >>> Follow the link for a detailed example: http://www.python.org/cgi-bin/moinmoin/RepresentationError |
|||
msg4859 - (view) | Author: David Waggle (darkmo0d) | Date: 2001-05-24 21:23 | |
Logged In: YES user_id=206710 The code/output that follows is what results from using the python tutorial. So, I grasp the concept of the binary floating point "situation". No problem. But it took all day and a bug report to elicit canned-text. So not only am I expericencing a "RepresentationError", but so is the python tutorial. No where in chap/sec 5.1 on pp 29-30 does it mention this and it is quite confusing to a newbie when the teacher's answers and the student's answers do not match. According to the tutorial this code/output should be what I see when passed through the interpreter: >>>a = [66.6, 333, 333, 1, 1234.5] >>>a [66.6, 333, 333, 1, 1234.5] but I see: Python 2.1 (#1, May 24 2001, 09:28:32) [GCC 2.95.3 20010315 (release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> a = [66.6, 333, 333, 1, 1234.5] >>> a [66.599999999999994, 333, 333, 1, 1234.5] >>> str(a) '[66.599999999999994, 333, 333, 1, 1234.5]' >>> str(a[0]) '66.6' >>> str(a[0:3]) '[66.599999999999994, 333, 333]' >>> str(a[0:1]) '[66.599999999999994]' >>> str(a[0:]) '[66.599999999999994, 333, 333, 1, 1234.5]' So point taken and logged. So if you know the guy who wrote the docs, or are the guy who wrote the docs: Take my point into consideration. Docs can have bugs, too. |
|||
msg4860 - (view) | Author: Tim Peters (tim.peters) * | Date: 2001-05-24 23:34 | |
Logged In: YES user_id=31435 As I mentioned in email, the tutorial has already been repaired but the new version has not yet been released (it will for be for 2.2). Also (probably) adding a new Appendix (see your email). Didn't understand the "all day" comment -- looks like you got a response in less than 2 hours (yes, a canned one, but had you searched the bug database you would have found many repetitions of this basic complaint on your own -- indeed, that's why a canned response exists <wink>). |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:04:05 | admin | set | github: 34542 |
2001-05-24 19:40:14 | darkmo0d | create |