Can't set a random number to less than zero

Apr 09, 2020

I can't seem to set a random number less than zero! I can set a fixed number to less than zero, but not a random number.

2 Replies
Katie Riggio

Happy Friday and good question, Stephen!

Random number variables accept whole numbers only, and the widest acceptable range is 0 to 2,147,483,647. Decimals aren't supported.

To generate random decimals, you can use a high range of values such as 100 to 1,000 and then divide the number variable by 10, 100, etc.

To dive deeper, check out these related resources: 

Ned Whiteley

Hi Stephen,

Problem solved !

In the attached example, I have used two random number generated variables; RandomNumber, which provides your final output and RandomNegative, which determines whether the number will be positive or negative.

When you click on the "Generate Random Number" button, the first thing that happens is that RandomNumber generates a number between 0 and 10. Next, RandomNegative generates a number between 0 and 1. Finally, RandomNumber is multiplied by -1 if RandomNegative = 1.

The final result (the new value of RandomNumber) is displayed above the button on the slide.

If you want a larger range of numbers, you simply increase the range of RandomNumber in the first trigger.

This discussion is closed. You can start a new discussion or contact Articulate Support.