Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison of two ints returns wrong result #48560

Closed
kbrandt mannequin opened this issue Nov 12, 2008 · 2 comments
Closed

Comparison of two ints returns wrong result #48560

kbrandt mannequin opened this issue Nov 12, 2008 · 2 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@kbrandt
Copy link
Mannequin

kbrandt mannequin commented Nov 12, 2008

BPO 4310
Nosy @mdickinson
Files
  • id_11-2.py: The Code that doesn't work correctly
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2008-11-12.21:26:54.513>
    created_at = <Date 2008-11-12.21:07:24.870>
    labels = ['type-bug', 'invalid']
    title = 'Comparison of two ints returns wrong result'
    updated_at = <Date 2008-11-12.21:26:54.504>
    user = 'https://bugs.python.org/kbrandt'

    bugs.python.org fields:

    activity = <Date 2008-11-12.21:26:54.504>
    actor = 'mark.dickinson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-11-12.21:26:54.513>
    closer = 'mark.dickinson'
    components = []
    creation = <Date 2008-11-12.21:07:24.870>
    creator = 'kbrandt'
    dependencies = []
    files = ['11996']
    hgrepos = []
    issue_num = 4310
    keywords = []
    message_count = 2.0
    messages = ['75794', '75798']
    nosy_count = 2.0
    nosy_names = ['mark.dickinson', 'kbrandt']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue4310'
    versions = ['Python 2.5']

    @kbrandt
    Copy link
    Mannequin Author

    kbrandt mannequin commented Nov 12, 2008

    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.

    @kbrandt kbrandt mannequin added the type-bug An unexpected behavior, bug, or error label Nov 12, 2008
    @mdickinson
    Copy link
    Member

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant