mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Be explicit about corner cases for llFrand.
inf and nan already did the right thing in Python, but just in case that doesn't happen in all platforms, we handle them explicitly. Also, that will make it more immune to bugs in future.
This commit is contained in:
parent
2327613423
commit
fc97ce42df
1 changed files with 5 additions and 0 deletions
|
@ -1058,6 +1058,11 @@ if lslcommon.IsCalc:
|
||||||
import random
|
import random
|
||||||
def llFrand(lim):
|
def llFrand(lim):
|
||||||
assert isfloat(lim)
|
assert isfloat(lim)
|
||||||
|
if math.isinf(lim):
|
||||||
|
return 0.
|
||||||
|
if math.isnan(lim):
|
||||||
|
return lim
|
||||||
|
|
||||||
lim = F32(lim) # apply constraints
|
lim = F32(lim) # apply constraints
|
||||||
val = random.random() * lim
|
val = random.random() * lim
|
||||||
# Truncate, rather than rounding
|
# Truncate, rather than rounding
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue