Generate Random Decimal Numbers
Generate up to 1,000 random decimal numbers between any two values with 0 to 10 decimal places. Choose an even spread or a bell curve with your own mean and standard deviation, avoid repeats, sort them, and copy with a decimal point or comma.
Exact decimal values · both bounds included
Every Value on the Grid Equally Likely
With 1 decimal place between 0 and 1 there are exactly 11 possible results: 0.0, 0.1, … 1.0. The common shortcut, picking any real number in the range and rounding it, doesn't treat them equally. Only numbers from 0 to 0.05 round to 0.0, while 0.05 to 0.15 rounds to 0.1, so the two end values get half the share of the others.
| Result | Round a random real number | This page |
|---|---|---|
| 0.0 | 5% | 9.09% (1 in 11) |
| 0.1 to 0.9, each | 10% | 9.09% (1 in 11) |
| 1.0 | 5% | 9.09% (1 in 11) |
This page counts the values on the grid and picks one of them directly, using whole-number arithmetic so there is no rounding at all. If a bound has more decimals than you asked for, it is moved inward to the nearest grid value: a minimum of 0.125 at 2 places starts at 0.13, so no result can fall outside your range.
Worked Example: 30 Bag Weights Around 502 g
A quality-control trainer needs a realistic sample for a spreadsheet exercise: 30 bags of rice labelled 500 g, filled by a machine set slightly high, weighed to 0.1 g. Real fill weights cluster around the target, so an even spread would look wrong.
Settings (the "Bag weights" preset)
What to expect
The exercise
The range is a hard limit; the standard deviation sets how tightly values cluster. Here 495 and 510 are about 3 standard deviations from the mean, so the cut-off removes almost nothing. Compare the Mean and Std deviation tiles with 502 and 2.5: with 30 values the mean is usually within about 1 g of 502.
Even Spread or Bell Curve?
Use the even spread when any value is as plausible as any other: sample prices, coordinates, a random point on a scale, or test inputs that should cover the whole range. Use the bell curve for things that vary around a typical value: heights, weights, measurement error, reaction times, exam marks.
In a normal distribution about 68% of values are within 1 standard deviation of the mean, 95% within 2 and 99.7% within 3. Leave the mean and standard deviation blank and the page centres the curve in your range with the range spanning ±3 standard deviations. Values drawn outside the range are thrown away and redrawn, so if the range is narrow compared with the standard deviation, the result is flatter than a true bell curve.
| Within | Share of values | Bag example (mean 502, SD 2.5) |
|---|---|---|
| ±1 SD | 68.3% | 499.5 to 504.5 g |
| ±2 SD | 95.4% | 497.0 to 507.0 g |
| ±3 SD | 99.7% | 494.5 to 509.5 g |
Decimals That Change When You Paste Them
The numbers here are exact decimal text. Most software stores them as binary floating-point instead, which can't represent most decimals exactly, and that shows up in test data:
- In JavaScript,
0.1 + 0.2is0.30000000000000004, and(1.005).toFixed(2)gives"1.00", not 1.01, because 1.005 is stored as slightly less than 1.005. - Excel keeps 15 significant digits. A value such as 1234567.123456789 loses its last digits when pasted.
- For money, store whole cents (or a decimal type such as SQL
DECIMAL(10,2)), not floats.
That makes generated decimals useful for testing rounding: values ending in 5 at the last place, such as 2.675, are exactly where float-based rounding goes wrong.
Decimal Comma or Decimal Point
Much of Europe, Latin America and Africa writes 3,14 where the UK and US write 3.14. A spreadsheet set to one convention may read the other as text, or as a date. Tick Decimal comma to output 3,14 style; the comma separator then switches to a semicolon so the list still splits correctly, which matches how those locales write CSV files.
The minimum and maximum accept either style, so typing 2,5 works the same as 2.5. Don't use thousands separators in the bounds.
Random Decimals in Excel, Python and JavaScript
Excel / Google Sheets: 5.00 to 50.00, every cent equally likely
=RANDBETWEEN(500, 5000) / 100Excel: bell curve, mean 502, SD 2.5, 1 decimal
=ROUND(NORM.INV(RAND(), 502, 2.5), 1)Python
import random
from decimal import Decimal
Decimal(random.randint(500, 5000)) / 100 # 5.00 to 50.00, exact
random.gauss(502, 2.5) # bell curveJavaScript
// whole cents, then divide only for display
const cents = 500 + Math.floor(Math.random() * 4501);
(cents / 100).toFixed(2);The pattern in each is the same as on this page: pick a whole number of the smallest step, then divide. The tempting =ROUND(RAND()*45+5, 2) has the half-chance problem at both ends, and Python's random.uniform(a, b) may or may not ever return b exactly. For whole numbers only, use the random integer list generator.
Frequently asked questions
Are the minimum and maximum included?
Yes. With an even spread every value on the grid, including both bounds, has the same chance. A bound with more decimals than you chose is moved inward to the nearest value at that precision.
How do I get random numbers between 0 and 1?
Enter 0 and 1 and choose the decimal places. At 3 places there are 1,001 possible values, from 0.000 to 1.000. Use the Probabilities preset for a quick start.
Why does the mean differ from the middle of my range?
It is the mean of this sample, not the theoretical one. With 10 values it can easily sit some way from the centre; with 1,000 it will be close.
Can I generate normally distributed decimals?
Yes. Set Spread to Bell curve and enter a mean and standard deviation. Results outside the minimum and maximum are redrawn, so set the range at least 3 standard deviations either side of the mean for an untrimmed bell curve.
Sources
- NIST/SEMATECH e-Handbook: Uniform Distribution: every value in the range equally likely.
- NIST/SEMATECH e-Handbook: Normal Distribution: mean, standard deviation and the bell-shaped density.
- Python documentation: random module: uniform() may or may not include the end point; gauss().
- MDN: Number.prototype.toFixed(): rounding surprises such as 1.005.toFixed(2).
- Microsoft Learn: Floating-point arithmetic may give inaccurate results in Excel: 15 digits of precision.
- Microsoft Support: NORM.INV function: turning RAND() into a normally distributed value.
- David Goldberg: What Every Computer Scientist Should Know About Floating-Point Arithmetic: why most decimals are not exact in binary.
Related Tools
Create GUIDs for Microsoft and .NET fields.
Generate binary numbers with a chosen bit length.
Create a random pixel image and save it as a PNG.
Generate bytes in hex, Base64, or decimal format.
Pick a date between your chosen start and end dates.
Generate fractions and see their simplified forms.