Random Number Generator
How This Converter Works
Uses Math.random with the entered finite minimum and maximum. The inputs are not required to be integers, but the formula only stays within the bounds when their difference is an integer; fractional bounds can produce values above the maximum (for example, 0.2 to 0.8 can produce 1.2).
Formula or rule
floor(Math.random() * (max - min + 1)) + min. Invalid/non-finite bounds or min > max display a validation message; fractional bounds are not reliably kept within range.
Example
- Input
- Minimum -2; maximum 2
- Calculation
- One possible Math.random() value yields a value in the inclusive range -2 through 2.
- Result
- 1 (one possible result)