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.

Title: Comparison of two ints returns wrong result
Type: behavior Stage:
Components: Versions: Python 2.5
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 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit 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 | grep 70600 
<type 'int'> <type 'int'> 70600674 51267216
# python | 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
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.
Date User Action Args
2022-04-11 14:56:41adminsetgithub: 48560
2008-11-12 21:26:54mark.dickinsonsetstatus: open -> closed
resolution: not a bug
messages: + msg75798
nosy: + mark.dickinson
2008-11-12 21:07:24kbrandtcreate