mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
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:
parent
80cbaf8fd5
commit
27adfdbfb9
1 changed files with 1 additions and 1 deletions
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue