# Decimal Random Number Generator

URL: https://speedycalculator.com/calculators/statistics/decimal-random-number-generator/
Last updated: 2026-10-30

> The decimal random number generator draws random numbers with up to ten decimal places between any two limits – such as 0 to 1 or 2.5 to 7.5 – with a choice of how many numbers, whether endpoints and repeats are allowed, sorting, and list or column output.

## Inputs

- Minimum value
- Maximum value
- How many numbers
- Decimal places (precision, 0 = whole numbers)
- Include the minimum and maximum?
- Duplicates
- Sort
- Output layout

## Results

- Random decimals
- Mean
- Sum
- Smallest
- Largest
- Possible values
- Spread of the numbers

## Formula

```
x = a + ⌊u × ((b − a)·10ᵈ + 1)⌋ ÷ 10ᵈ, u uniform on [0, 1) · with d decimals there are (b − a)·10ᵈ + 1 possible values · d = 0 gives whole numbers
```

## Explanation

Many tasks need random values that are not whole numbers: test data for a spreadsheet, simulated measurements, random probabilities between 0 and 1, prices with cents or coordinates for a scatter of points. A decimal generator scales a uniform random number in [0, 1) to the interval you want and rounds it to a fixed number of decimal places, so every value on that grid is equally likely.

The precision matters. Between 0 and 1 there are 11 possible values with one decimal place, 101 with two and 1,001 with three, so repeats become rarer as you add places. Set the precision to 0 and the tool produces integers instead. You decide whether the endpoints may appear, whether repeated values are allowed, and whether the list stays in the order drawn or is sorted.

The output can be a comma-separated list, convenient for pasting into one line, or a column with one number per line for spreadsheets. The tool also reports the sum, mean, smallest and largest value and the number of possible values, and draws a histogram for longer lists so you can see the even spread.

### How to use the Decimal Random Number Generator

- **Minimum value**
- **Maximum value**
- **How many numbers**
- **Decimal places (precision, 0 = whole numbers)**
- **Include the minimum and maximum?**
- **Duplicates**
- **Sort**
- **Output layout**

Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.

### How it works

The tool turns the limits into a grid of values spaced 10⁻ᵈ apart, removes excluded endpoints and draws from the grid with a cryptographically secure random generator, using rejection of repeats when duplicates are not allowed.

### Worked example

Five numbers between 0 and 1 with three decimal places came out 0.593, 0.028, 0.292, 0.681 and 0.929. Each came from 1,001 possible values; their mean, 0.5046, is close to the expected 0.5. Between 2.5 and 7.5 with one decimal place there are 51 possible values (2.5, 2.6, … 7.5).

### Possible values by precision (range 0 to 1)

Decimal placesStepPossible values01210.11120.0110130.0011,00160.0000011,000,001

## Worked example

Inputs — Minimum value: 0; Maximum value: 1; How many numbers: 10; Decimal places (precision, 0 = whole numbers): 3; Include the minimum and maximum?: Include both; Duplicates: Allow repeated numbers; Sort: No – keep the order drawn; Output layout: List (comma-separated).

Results — **Random decimals = 0.480, 0.475, 0.275, 0.086, 0.521, 0.241, 0.642, 0.170, 0.155, 0.156**; Mean = 0.3201; Sum = 3.201; Smallest = 0.086; Largest = 0.642; Possible values = 1,001 possible values (step 0.001).

## Key terms

- **Precision**: The number of decimal places in each generated value.
- **Uniform distribution on an interval**: Every value in the interval (or on its grid) is equally likely.
- **Rejection sampling**: Drawing again whenever a value is not allowed, such as a repeat.

## FAQ

**How do I generate a random decimal between 0 and 1?**
Set the minimum to 0, the maximum to 1 and the decimal places you need; with 3 places each of the 1,001 values 0.000 … 1.000 is equally likely.

**How do I get a random decimal between a and b by hand?**
Take a uniform random number u between 0 and 1 and compute a + u × (b − a), then round.

**Why do I get repeats?**
With few decimal places there are few possible values. Add decimal places or choose "No repeats".

**What does precision 0 do?**
It rounds to whole numbers, turning the tool into an integer generator.

**Is 2 the same as 1.999…?**
Mathematically yes, which is why the generator works on a fixed grid of rounded values rather than "all real numbers".

**Can I paste the numbers into Excel or Google Sheets?**
Yes – choose the column layout and paste; each number lands in its own row.

**Are the numbers truly random?**
They come from the browser's cryptographically secure generator, which is unpredictable in practice; physically random sources such as atmospheric noise are used by specialist services.


## Sources

- [MDN – Crypto.getRandomValues()](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues)
- [RANDOM.ORG – Introduction to randomness and random numbers](https://www.random.org/randomness/)
- [NIST/SEMATECH e-Handbook of Statistical Methods](https://www.itl.nist.gov/div898/handbook/)
