Random decimal generator with the precision you choose
This random decimal generator produces numbers with a fractional part, such as 0.7342 or 128.05. You set the range and the number of decimal places, and each value is drawn uniformly from the range using 53 bits of cryptographically secure randomness, the full precision of a JavaScript double.
Values are rounded to the requested decimal places, so with 2 decimals you get prices like 17.40, trailing zeros included, which keeps columns neatly aligned.
Examples
| Settings | Sample output |
|---|---|
| 0 to 1, 4 decimals | 0.3187, 0.9021, 0.0456 |
| 9.99 to 499.99, 2 decimals | 42.18, 311.90, 87.04 |
| -90 to 90, 6 decimals (latitude) | 47.608013, -33.868820 |
| 35.5 to 39.5, 1 decimal (body temperature °C) | 36.8, 38.1 |
What to use random decimals for
- Sample prices and amounts for e-commerce demos, invoices and charts.
- Sensor-style readings such as temperature, humidity or voltage for dashboards and IoT prototypes.
- Coordinates within a bounding box for map testing.
- Probabilities and weights between 0 and 1 for simulations and machine-learning experiments.
- Precision tests that check how your code rounds and formats numbers.
A note on floating-point precision
Computers store most decimals in binary, which cannot represent values like 0.1 exactly. That is why 0.1 + 0.2 evaluates to 0.30000000000000004 in JavaScript and many other languages. The generator formats each number as text with exactly the decimals you asked for, but once you import the values into code and add them up, tiny rounding errors can appear. For money, store amounts as integer cents or use a decimal type in your database.
Very high precision settings (more than about 15 significant digits in total) exceed what a double can hold, so the last digits are not meaningful.
Negative ranges and mixed signs
Bounds can be negative, for example -1 to 1 for normalized values or -180 to 180 for longitudes. The sign is handled correctly, and rounding applies to the absolute number of decimal places you choose.
Distribution
Numbers are spread uniformly: every sub-interval of the same width is equally likely. Real-world measurements are often bell-shaped instead; to approximate a normal distribution you can average several uniform values in a spreadsheet.
For whole numbers use the random number generator, and for exact fractions such as 3/8 try the random fraction generator. Everything runs in your browser; no values are sent to a server.