Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialmichelle Jia
4,814 Pointswhat if the 1st number input is bigger than the 2nd number input, you will get a negative result?
topnumber and bottom number
1 Answer
Steven Parker
231,271 PointsIf you're using the standard formula, you probably will not see a negative number, since the first number (which will now be the larger one) is added to random number multiplied by the (now negative) range. In fact, it may even seem not to make any difference which order the numbers are given in.
But if you did a thorough analysis of the generated numbers, you would notice that the distribution is not even across the possible results as it would be when the numbers are entered in the correct order.