How to start Math.Random at a specific number?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • IanSD81
    New Member
    • Feb 2008
    • 6

    How to start Math.Random at a specific number?

    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?
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    A perfectly valid question.

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

    To get numbers between 53 and max:
    [code=javascript]Math.floor(Math .random()*(max-52))+53[/code]

    Comment

    Working...