Small Integer Generator

Generates a requested count of random integers in the symmetric range [-maxMagnitude, maxMagnitude], one per line, useful for quick small sample values around zero. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-27

Overview

Introduction

This tool generates a batch of small random integers, centered symmetrically around zero, for quick sample data or testing.

Set how many values you want and the maximum magnitude, and it prints one integer per line.

What Is Small Integer Generator?

A generator that produces a requested count of random integers drawn uniformly from the symmetric range [-maxMagnitude, maxMagnitude].

It's aimed at small, easy-to-eyeball sample values, unlike range-based generators that accept arbitrary Min/Max bounds.

How Small Integer Generator Works

For each requested value, the tool draws a uniformly random integer between -maxMagnitude and maxMagnitude inclusive.

Every value is printed on its own line.

When To Use Small Integer Generator

Use it to generate quick sample values for testing code that handles both positive and negative small numbers (e.g. offsets, deltas, signed adjustments).

It's also handy for teaching demonstrations needing a simple randomized list of small integers.

Features

Advantages

  • Symmetric around zero by construction, so positive, negative, and zero values are all represented.
  • Simple single-control range (max magnitude) instead of separate Min/Max inputs.
  • Plain text output, one value per line, that pastes cleanly anywhere.

Limitations

  • Always symmetric around zero; it can't generate an asymmetric range like [-3, 10] (use the Integer Vector Generator for that).
  • Max magnitude is capped at 99 to keep the values genuinely small.
  • Uses Math.random(), so it is not suitable for cryptographic or security-sensitive randomness.

Examples

5 values with default magnitude

Input

count=5, maxMagnitude=9

Output

-3
7
0
-9
4

Five independent random integers between -9 and 9 (exact values vary run to run).

3 values with a smaller magnitude

Input

count=3, maxMagnitude=2

Output

-1
2
0

Three independent random integers between -2 and 2.

Best Practices & Notes

Best Practices

  • Lower the max magnitude if you need values that are easy to verify by eye.
  • Use Regenerate to get a fresh batch without changing your count/magnitude settings.

Developer Notes

Each value is computed as `Math.floor(rng() * (2 * maxMagnitude + 1)) - maxMagnitude`, with `rng` defaulting to `Math.random` but overridable (e.g. in tests) for deterministic output.

Small Integer Generator Use Cases

  • Generating sample signed offsets or deltas for testing
  • Producing small randomized numeric test fixtures
  • Quick teaching examples of a symmetric random distribution

Common Mistakes

  • Expecting an asymmetric range; the range is always [-maxMagnitude, maxMagnitude].
  • Requesting a max magnitude above the 99 cap.
  • Assuming values are unique; repeats are possible since each is drawn independently.

Tips

  • Use max magnitude 1 to quickly generate a random sequence of -1, 0, and 1.
  • Combine with the Integer Average Calculator to check the sample mean is close to zero.

References

Frequently Asked Questions