[issue10346] strange arithmetic behaviour

Alexey Radkov report at bugs.python.org
Sun Nov 7 11:40:20 CET 2010


New submission from Alexey Radkov <alexey.radkov at gmail.com>:

The following excerpt will show the issue:

$ python
Python 2.7 (r27:82500, Sep 16 2010, 18:02:00) 
[GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 8 * 4 / ( 2 - 7 ) * 6 / 3
-14
>>>

Why it is evaluated to -14 ?? In floating point arithmetic it should be -12.8, in integer arithmetic i believe it should be -12 (at least bc and a small dedicated C program evaluate it to -12). Perhaps i do not understand some specific python arithmetic priority or associativity rules, anyway i cannot find a specific combinations of them to yield -14 in this expression.

----------
components: None
messages: 120665
nosy: alexey.radkov
priority: normal
severity: normal
status: open
title: strange arithmetic behaviour
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10346>
_______________________________________


More information about the Python-bugs-list mailing list