Ensure that floats are compared with 32-bit precision.

The equality operator was comparing the raw floats when two were given. Also, type() was called when it was not needed.
This commit is contained in:
Sei Lisa 2017-01-17 02:38:52 +01:00
parent 6591b5dfd8
commit c8bfd40c66

View file

@ -744,10 +744,10 @@ def compare(a, b, Eq = True):
tb = type(b) tb = type(b)
if ta in (int, float) and tb in (int, float): if ta in (int, float) and tb in (int, float):
# we trust that NaN == NaN is False # we trust that NaN == NaN is False
if type(a) != type(b): if ta == tb == int:
ret = ff(a) == ff(b)
else:
ret = a == b ret = a == b
else:
ret = ff(a) == ff(b)
return int(ret) if Eq else 1-ret return int(ret) if Eq else 1-ret
if ta in (unicode, Key) and tb in (unicode, Key): if ta in (unicode, Key) and tb in (unicode, Key):
ret = 0 if a == b else 1 if a > b or not lslcommon.LSO else -1 ret = 0 if a == b else 1 if a > b or not lslcommon.LSO else -1