From c8bfd40c666759c622bf57ba46473566950b2e63 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Tue, 17 Jan 2017 02:38:52 +0100 Subject: [PATCH] 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. --- lslopt/lslbasefuncs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lslopt/lslbasefuncs.py b/lslopt/lslbasefuncs.py index 7efdaa2..f2e093c 100644 --- a/lslopt/lslbasefuncs.py +++ b/lslopt/lslbasefuncs.py @@ -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