bin: Fixed float decoding bug. master
authorFredrik Tolf <fredrik@dolda2000.com>
Mon, 27 Jun 2022 12:58:37 +0000 (14:58 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Mon, 27 Jun 2022 12:58:37 +0000 (14:58 +0200)
coe/bin.py

index 08e521e..e9efc80 100644 (file)
@@ -302,15 +302,15 @@ class decoder(object):
                 exp = self.loadint(buf)
                 if mnt == 0:
                     if exp == 0:
-                        return 0.0
+                        ret = 0.0
                     elif exp == 1:
-                        return -0.0
+                        ret = -0.0
                     elif exp == 2:
-                        return float("inf")
+                        ret = float("inf")
                     elif exp == 3:
-                        return -float("inf")
+                        ret = -float("inf")
                     else:
-                        return float("nan")
+                        ret = float("nan")
                 else:
                     ret = math.ldexp(mnt, exp - (mnt.bit_length() - 1))
                 return self.addref(ret)