Work
Integer draw and range width
Adding one to the width before truncating makes both endpoints reachable, so an integer draw from 1 to 100 can return either 1 or 100.
The Formula
integer value = floor(min + u x (max - min + 1))
Adding one to the width before truncating makes both endpoints reachable, so an integer draw from 1 to 100 can return either 1 or 100.
| Symbol | Meaning | Unit | Notes |
|---|---|---|---|
| min | Minimum | value | The smallest integer the draw may return. |
| max | Maximum | value | The largest integer the draw may return. |
| v | Drawn integer | value | The truncated result. |
What Each Symbol Means
minvalue
Minimum
The smallest integer the draw may return.
maxvalue
Maximum
The largest integer the draw may return.
vvalue
Drawn integer
The truncated result.
See It Worked With Real Numbers
A formula on its own does not tell you which number goes where. The how to generate random numbers page applies this equation to a concrete case, shows every intermediate step, and names the mistakes that produce a wrong answer even when the algebra is right.
Where This Formula Appears
This equation is the working core of How To Generate Random Numbers, filed under Everyday Life. Every number the guide produces comes from substituting into this one line.