Random Numbers Made EZ!
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Math.getRandInt.js
Math.getRandInt.min.js
Math.rand.js
README.md
getRandInt.all.min.js
jQuery.getRandInt.js
window.getRandInt.js
window.getRandInt.min.js

README.md

getRandInt - Random Numbers Made EZ!

As Seen @ http://spyk3lc.blogspot.com/2016/04/javascript-get-random-number-between.html

This simple and easy to use method allows you to quickly and easly get a random Float, whole Int, or n Decimal long String Random Number based on 2 given numbers. Provide "min" & "max" in order to get any random number from the minimum to the maximum. OR, swap the order of the parameters and ensure you never get the exact minimum or maximum numbers, but always a random number between the two!

Quick Links

Example Use

  • getRandInt(1, 2) = 1.2783833924813244 // Will be any Number from min to max
  • getRandInt(1, 2, false) = 1.048028815274805 // Will be any Number from min to max
  • getRandInt(1, 2, true) = 1 // Will be any Whole Number from min to max
  • getRandInt(1, 2, 19) = 1.5612295703389058588 // Will have 19 decimal places.
  • getRandInt(2, 1) = 1.3221148112756618 // Will never equal 2 or 1

jsFiddle