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:
@@ -1058,6 +1058,11 @@ if lslcommon.IsCalc:
|
||||
import random
|
||||
def llFrand(lim):
|
||||
assert isfloat(lim)
|
||||
if math.isinf(lim):
|
||||
return 0.
|
||||
if math.isnan(lim):
|
||||
return lim
|
||||
|
||||
lim = F32(lim) # apply constraints
|
||||
val = random.random() * lim
|
||||
# Truncate, rather than rounding
|
||||
|
||||
Reference in New Issue
Block a user