Advertisement
ulfben

Get random number between min and max

Dec 7th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Returns a random number between min (inclusive) and max (exclusive)
  2. function getRandom(min:Number, max:Number):Number {
  3.     return Math.random() * (max - min) + min;
  4. }
  5.  
  6. //Returns a random integer between min (inclusive) and max (inclusive)
  7. function getRandomInt(min, max):int {
  8.     return Math.floor(Math.random() * (max - min + 1)) + min;
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement