From 27adfdbfb9c2b657515b2a3a0d2d416a54ee6b97 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Tue, 24 Jan 2017 05:50:07 +0100 Subject: [PATCH] Fix llRound behaviour in corner cases. We had too much precision. In LSL, llRound(0.49999997) gives 1, not 0, because the loss of precision after adding 0.5 to that makes the result 1. Fixed by converting to F32 prior to flooring. --- lslopt/lslbasefuncs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lslopt/lslbasefuncs.py b/lslopt/lslbasefuncs.py index 0ed6a7a..cd038ce 100644 --- a/lslopt/lslbasefuncs.py +++ b/lslopt/lslbasefuncs.py @@ -1697,7 +1697,7 @@ def llRound(f): assert isfloat(f) if math.isnan(f) or math.isinf(f) or f >= 2147483647.5 or f < -2147483648.0: return -2147483648 - return int(math.floor(f+0.5)) + return int(math.floor(F32(f+0.5))) def llSHA1String(s): assert isstring(s)