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.
This commit is contained in:
Sei Lisa 2017-01-24 05:50:07 +01:00
parent 80cbaf8fd5
commit 27adfdbfb9

View file

@ -1697,7 +1697,7 @@ def llRound(f):
assert isfloat(f) assert isfloat(f)
if math.isnan(f) or math.isinf(f) or f >= 2147483647.5 or f < -2147483648.0: if math.isnan(f) or math.isinf(f) or f >= 2147483647.5 or f < -2147483648.0:
return -2147483648 return -2147483648
return int(math.floor(f+0.5)) return int(math.floor(F32(f+0.5)))
def llSHA1String(s): def llSHA1String(s):
assert isstring(s) assert isstring(s)