Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Bug] randomInteger returning between 0 and max-1 instead of 1 and max

This page specifies that randomInteger will return between 1 and MAX:&nbsp; <a href="https://wiki.roll20.net/API:Utility_Functions#Random_Numbers" rel="nofollow">https://wiki.roll20.net/API:Utility_Functions#Random_Numbers</a> &nbsp; I was getting some odd results in an API script I was writing and found that randomInteger was returning between 0 and max - 1, not 1 and max. A simple loop to 100 with results. "14, 3, 17, 12, 10, 5, 5, 10, 6, 11, 4, 14, 6, 18, 0, 11, 11, 17, 16, 3" "6, 9, 10, 19, 15, 11, 6, 19, 17, 5, 19, 0, 2, 17, 13, 16, 13, 9, 2, 5" "17, 1, 3, 1, 3, 9, 9, 12, 12, 2, 10, 3, 17, 10, 19, 16, 11, 17, 17, 4" "19, 17, 18, 14, 5, 3, 15, 2, 8, 12, 13, 5, 2, 17, 12, 3, 10, 2, 7, 15" "16, 9, 14, 18, 4, 9, 12, 16, 18, 7, 17, 14, 17, 9, 9, 18, 5, 7, 3, 9" Is this the intended functionality and the wiki wrong or a bug? For now I will simply add 1 to my randomInteger results. Code to reporduce results:&nbsp; <a href="https://gist.github.com/anonymous/5851475" rel="nofollow">https://gist.github.com/anonymous/5851475</a>
1372095017
Gauss
Forum Champion
Moved to API and added [Bug] to the title since this is an API issue. - Gauss
This is a bug, the docs are correct. Pushing out a fix now. EDIT: Should be fixed! Thanks!
Awesome, getting the correct results now, thanks!