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.
Often used alongside Big Integer Generator and Integer Vector Generator.
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
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.