On slide 3, I’m trying to create a self-checking random number generator for subtracting decimals. This code works well for adding, but it’s possible some generated numbers could result in negative numbers and I’m trying to prevent that.
I’m trying to do something to the effect of checking to see if the outcome is negative and if so, make the first number the largest possible (50).
Thanks for your help.
The simplest option is just to fix the upper bound of the randomly generated num2 to be num1 - this way, num2 will always be between 0 and num1:
num2 = numericValue("\operatorname{round}(${r.float(0,num1)},2)")
And thus the resulting subtraction will always be positive.
Well, that makes perfect sense. Thank you, so much!