ForHosting KIT · Math

Decimal random number generator

With bounds 0 and 1 and seed 42 you always get 0.2523451748: the same bounds, seed and number of decimals replay the same draw. Useful for answer keys, probability exercises and sample data that someone else must be able to check. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Minimum
0
Maximum
1
Seed
42
You get
Value
0.2523451748
Precision
10
Unit interval
0.2523451748

The draw comes from a seeded linear congruential generator, so the same bounds, seed, and precision always produce the same number.

How a seeded linear congruential generator becomes one decimal

A decimal random number generator that cannot be replayed is a liability in tests, homework keys, and simulation notebooks. One step of the recurrence produces an unsigned integer X, which is divided by two to the thirty-two to obtain a unit-interval sample u in the half-open range from zero inclusive to one exclusive. That unit sample is then scaled onto the caller’s interval by the affine map value equals minimum plus u times the width maximum minus minimum.

Before any rounding, the raw decimal therefore lives in the half-open interval that includes the minimum and excludes the maximum. Optional precision then rounds the displayed decimal to between zero and twelve fractional digits so goldens and spreadsheets compare byte for byte.

Input contract, bounds, precision, and error behaviour

An optional precision field, also accepted as decimals, places, or digits, sets the number of fractional digits in the returned decimal; it defaults to ten and must be an integer from zero through twelve. The hard geometric rule is that minimum must be strictly less than maximum. Equal bounds and a reversed interval are both rejected, because a zero or negative width does not define a uniform draw and inventing a swap would hide a caller bug.

On success the body echoes the parsed minimum, maximum, the unsigned 32-bit seed that actually entered the recurrence, and the precision that was applied. Failed validation is not billed. Pair the echoed seed with your own records if you need to prove that a later replay used the same stream.

Where a replayable decimal draw earns its keep

Software tests are the first audience. A suite that needs a decimal between 0.15 and 0.85 should not call the host random source and then snapshot a moving number; it should send a fixed seed and assert the published value. Teaching platforms are the second.

Probability courses ask students to draw a uniform decimal on an interval and then compute a mean or a coverage; a seeded generator lets the instructor publish the expected draw next to the worksheet instead of arguing about whose calculator blinked. Simulation and mock-data jobs are the third. If you need many independent draws, advance the seed yourself (seed plus one, seed plus two) and collect the values, or call again with a different documented seed.

Keep requests small, pin the rounded value in tests, and you get a replayable decimal without standing up a statistics runtime of your own.

Classroom uniform draws

Publish the expected decimal next to a probability worksheet so every student and the answer key share one seeded draw.

Mock sensor and price series

Map a scenario identifier to a seed and obtain a stable temperature, weight, or unit price inside a documented numeric interval.

How does this decimal random number generator pick a value?

It advances a 32-bit Numerical Recipes linear congruential generator from your seed, maps the next state to a unit-interval sample u in [0, 1), then returns minimum + u × (maximum − minimum), rounded to the requested precision.

Why must the minimum bound be less than the maximum?

A uniform draw needs a positive interval width.

Is this a cryptographic random source?

No. The generator is a short, fully specified linear congruential stream meant for tests, teaching, and mock data. Do not use it for keys, tokens, or anything that must be unpredictable to an adversary.

How many decimal places can the number have?

Anywhere from 0 to 12. If you do not choose, the number comes with ten decimals. Rounding happens only at the end, after the draw has been placed between your two bounds.

How do I get several different random decimals?

Change the seed for each draw, for example by adding one each time, or use another seed that you write down. Each seed gives exactly one number, so repeating a seed repeats the same decimal.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/stat/decimal-random-number-generator

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/stat/decimal-random-number-generator \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"minimum":0,"maximum":1,"seed":42}'
{
  "minimum": 0,
  "maximum": 1,
  "seed": 42
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.decimal_random_number_generator",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

If the minimum bound is not strictly less than the maximum bound, the task fails with invalid_input rather than inventing an order.

How a seeded linear congruential generator becomes one decimal

This endpoint therefore refuses the host random source and the system clock. It advances a 32-bit linear congruential generator whose constants are the Numerical Recipes pair 1664525 and 1013904223, taken modulo two to the thirty-two. The same seed, bounds, and precision always yield the same unit_interval and the same value on every runtime that implements 32-bit multiply-add the same way, which is exactly the contract a continuous-integration assertion needs. Nothing in the path is stochastic at the operating-system level; two workers given the same JSON body cannot disagree.

Input contract, bounds, precision, and error behaviour

POST a JSON body with three required fields. minimum is the lower bound of the interval and may also arrive as min, lower, or lo. maximum is the upper bound and may also arrive as max, upper, or hi. seed is the generator seed and may also arrive as key or salt. Every numeric field may be a JSON number or a numeric string; non-finite values, empty strings, and missing required fields fail with invalid_input that names the field. It also returns unit_interval, the raw u rounded to twelve places for inspection, value, the scaled decimal rounded to the requested precision, and a short formula string that restates the affine map. Rounding after the scale can land exactly on an endpoint; treat the displayed value as a decimal with the requested number of places, not as a promise that the exclusive upper bound survives every rounding. Successful calls use the published $0.002 base price.

Where a replayable decimal draw earns its keep

Each successful API call costs $0.002; invalid input does not consume balance. The tool is not a cryptographic random source, not a multi-sample vector generator, and not a replacement for a full Monte Carlo library: it returns one decimal per request.

Replayable test fixtures

Pin a seed and bounds in continuous integration so a unit test always expects the same decimal instead of a moving host-random snapshot.

Will the same seed always produce the same decimal?

Yes. The path never reads the clock and never calls Math.random. The same minimum, maximum, seed, and precision always yield the same unit_interval and value.

What does the decimal random number generator cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →