[issue39436] Strange behavior of comparing int and float numbers

Petr Pisl report at bugs.python.org
Thu Jan 23 12:56:35 EST 2020


New submission from Petr Pisl <petrpisl at gmail.com>:

When python compares float and int created from the same int number should be equal like 

int(1) == float(1)

but from 9007199254740993 this is not true. 

int(9007199254740993) == float(9007199254740993) is not true. The same behavior is for bigger odd numbers. The even numbers are still equal. So it looks like:

int(9007199254740989) == float(9007199254740989) # True
int(9007199254740990) == float(9007199254740990) # True
int(9007199254740991) == float(9007199254740991) # True
int(9007199254740992) == float(9007199254740992) # True
int(9007199254740993) == float(9007199254740993) # False
int(9007199254740994) == float(9007199254740994) # True
int(9007199254740995) == float(9007199254740995) # False
int(9007199254740996) == float(9007199254740996) # True
int(9007199254740997) == float(9007199254740997) # False
int(9007199254740998) == float(9007199254740998) # True

----------
messages: 360571
nosy: Petr Pisl
priority: normal
severity: normal
status: open
title: Strange behavior of comparing int and float numbers
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39436>
_______________________________________


More information about the Python-bugs-list mailing list