mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
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:
parent
6591b5dfd8
commit
c8bfd40c66
1 changed files with 3 additions and 3 deletions
|
@ -744,10 +744,10 @@ def compare(a, b, Eq = True):
|
|||
tb = type(b)
|
||||
if ta in (int, float) and tb in (int, float):
|
||||
# we trust that NaN == NaN is False
|
||||
if type(a) != type(b):
|
||||
ret = ff(a) == ff(b)
|
||||
else:
|
||||
if ta == tb == int:
|
||||
ret = a == b
|
||||
else:
|
||||
ret = ff(a) == ff(b)
|
||||
return int(ret) if Eq else 1-ret
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue