Math.clamp fails to clamp -nan(ind)

###Test Cases:

print(math.clamp(1/0, 0, 0))
print(math.clamp(-1/0, 0, 0))
print(math.clamp(1/0 * 1/0, 0, 0))
print(math.clamp(1/0 * 0, 0, 0))
print(math.clamp(-1/0 * 0, 0, 0))
print(math.clamp((1/0) / (1/0), 0, 0))
print(math.clamp(0/0, 0, 0))

###Results:

> 0
> 0
> 0
> -nan(ind)
> -nan(ind)
> -nan(ind)
> -nan(ind)

###Notes:
It seems that multiplying -inf/inf (obtained by dividing a non-zero number by 0) by 0 or dividing 0 by 0 produces -nan(ind) which isn’t handled properly by math.clamp. Expected behavior is that this is treated like -inf.

3 Likes