By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,730 Members | 1,546 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,730 IT Pros & Developers. It's quick & easy.

How to start Math.Random at a specific number?

P: 6
This may be a stupid question but how can you start Math.Random() to start generating numbers after a specific number.
Say the number is 53 how do you call Math.random() so that it will not generate a number lower than 53?
Apr 30 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
A perfectly valid question.

Math.random generates a number between 0 and <1.

To get numbers between 53 and max:
Expand|Select|Wrap|Line Numbers
  1. Math.floor(Math.random()*(max-52))+53
Apr 30 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.