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:
Sei Lisa 2016-12-21 21:49:43 +01:00
parent 2327613423
commit fc97ce42df

View file

@ -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