Random Number Generator
Configuration
Show the math
What Your Result Means
- Integer: Whole numbers like 42, -5, or 0. Use when you need discrete values.
- Decimal: Numbers with fractional parts like 3.14 or 7.89. Use for continuous values.
- Range: The minimum and maximum bounds for generated numbers.
- Duplicates: Whether the same number can appear multiple times in your list.
How This Calculator Works
This random number generator uses the JavaScript Math.random() function, which produces cryptographically-suitable pseudo-random numbers between 0 and 1. The calculator scales and shifts these values to your specified range, then rounds or truncates as needed. For integers, it uses Math.floor() to ensure whole numbers. For decimals, toFixed() ensures the correct precision.
Quick Questions
Why do I get duplicates when I disabled them?
When requesting more unique numbers than possible in your range (e.g., 50 unique numbers from 1-10), the generator allows duplicates rather than failing. This is shown with a warning message.
Is this cryptographically secure?
Math.random() is suitable for games, simulations, and random selection. For security-sensitive applications (encryption, tokens), use a dedicated library like crypto.getRandomValues().
Can I generate negative numbers?
Yes. Set your minimum to any negative value and maximum to any higher value. The calculator handles negative ranges automatically.
Sources
- MDN Web Docs: Math.random() (official JavaScript documentation)
- Wikipedia: Pseudorandom Number Generator (background on PRNG algorithms)
- Random.org: Randomness (explanation of randomness sources)
Method & review
Estimate only. Results reflect your inputs and standard formulas. Double-check important decisions independently.