Understanding the Decimal Random Number Generator
A decimal random number generator produces a number with a fractional part — such as 3.72 or 0.4185 — chosen at random from a range you define. Unlike an integer generator, which returns whole numbers like 4 or 17, this tool returns values that can fall anywhere between your minimum and maximum, limited only by the number of decimal places you request.
The draw is uniform: every value in the interval is equally likely, so over many generations the results spread evenly across the range with no clustering toward the middle or the ends.
The formula
Each value is computed from a base random number u that is uniformly distributed on [0, 1):
- Scale and shift: value = min + (max − min) × u. This stretches the [0, 1) draw to fill your [min, max) range.
- Round: the raw value is then rounded to your chosen number of decimal places N. For example, N = 2 keeps two digits after the point (0.01 resolution); N = 4 gives 0.0001 resolution.
Because u comes from the half-open interval [0, 1), the underlying value spans [min, max) — it can equal the minimum but never reaches the maximum exactly, though rounding can occasionally display a value at the max boundary.
A worked example
Suppose min = 5, max = 10, and the base draw is u = 0.6. Then value = 5 + (10 − 5) × 0.6 = 5 + 3 = 8.0. If instead u = 0.25, value = 5 + 5 × 0.25 = 6.25. Every intermediate result is equally likely, so across many runs the average settles near the midpoint, (min + max) / 2 = 7.5.
Where it is used
- Simulation and Monte Carlo models: generating random inputs for prices, weights, arrival times, or measurement error.
- Sampling and A/B assignment: drawing a random fraction to route users into test groups.
- Teaching: demonstrating uniform distributions, rounding, and sampling variability in statistics classes.
- Games and procedural generation: randomizing coordinates, speeds, or probabilities with sub-integer precision.