Random Number Between Max and Min


/ Published in: ActionScript 3
Save to your folder(s)

Functions that returns a number between min & max, as integer or decimal.


Copy this code and paste it in your HTML
  1. public function getRandInt(_min:Number, _max:Number):int
  2. {
  3. return _min + Math.round(Math.random()*(_max - _min));
  4. }
  5.  
  6. public function getRandNum(_min:Number, _max:Number):Number
  7. {
  8. return _min +Math.random()*(_max - _min);
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.