SHARE
TWEET

Get random number between min and max

ulfben Dec 7th, 2015 71 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. }
RAW Paste Data
Top