classification
Title: Comparison of two ints returns wrong result
Type: behavior Stage:
Components: Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: kbrandt, mark.dickinson
Priority: normal Keywords:

Created on 2008-11-12 21:07 by kbrandt, last changed 2008-11-12 21:26 by mark.dickinson. This issue is now closed.

Files
File name Uploaded Description Edit
id_11-2.py kbrandt, 2008-11-12 21:07 The Code that doesn't work correctly
Messages (2)
msg75794 - (view) Author: Kyle Brandt (kbrandt) Date: 2008-11-12 21:07
The attached program returns a false result on one of my computers with
a Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz processor.  Is seems the
comparison of two int does not perform correctly.  I have python 2.5.2
and  2.6.27-7-generic kernel.

The lines of interest are 89-71:

print type(f_p),type(largest),f_p,largest
if f_p > largest:
     print 'foo'
     largest = f_p

When running this code:
# python id_11-2.py | grep 70600 
<type 'int'> <type 'int'> 70600674 51267216
# python id_11-2.py | grep foo #doesn't return anything

When I run the same code on another machine the end result of the
program is 70600674, whereas my current machine the end result is
51267216.
msg75798 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2008-11-12 21:26
You're mixing tabs and spaces in your code.

The 'if f_p > largest' line occurs one indentation level further out
than the preceding print.
History
Date User Action Args
2008-11-12 21:26:54mark.dickinsonsetstatus: open -> closed
resolution: not a bug
messages: + msg75798
nosy: + mark.dickinson
2008-11-12 21:07:24kbrandtcreate