Skip to main content

BorderlineData

Testing Numeric Boundaries

BLOG

How to Test Numeric Boundaries:

From Integers to Floating Points

Let’s talk about numbers. On paper, math is a beautiful, perfect language. In a computer, math is a chaotic circus where numbers occasionally mutate, disappear, or summon demons into your application.

If you think testing an integer input is as simple as typing 5, 10, and 100, welcome to the danger zone. Here is how you actually test numeric boundaries without getting bit.

The Integer Trap: Knowing Your Hardware Limits

Developers love data types. They have to use them to tell the computer how much memory to allocate for a number.

  • A standard 32-bit signed integer can only handle numbers up to 2,147,483,647.
  • Go one digit over that boundary (2,147,483,648), and depending on the language, the system will either throw a screaming error or wrap all the way around to -2,147,483,648.

Imagine a user checking their loyalty points and seeing a negative balance of two billion. That’s an unvalidated integer boundary bug in production.

The Floating-Point Nightmare

Then we have floats (decimals). Computers store decimals in binary (base-2), but humans write them in decimal (base-10). Because of this, computers literally cannot represent some fractions perfectly.

Open your browser’s developer console right now and type: 0.1 + 0.2.

You won’t get 0.3. You’ll get 0.30000000000000004.

If your application handles percentages, discounts, or measurements, this tiny rounding error can accumulate at scale.

Your Numeric Testing Checklist

When testing any numeric input field, don’t just test the business logic rules. Toss these exact values into the machine:

  1. The Extreme Limits: What happens at 0, -1, and negative values?
  2. The Precision Test: If it accepts decimals, pass 0.000001. Does it truncate it, round it, or crash the database?
  3. The Type Mix: Feed it text (“twelve”) or scientific notation (1e5). If the backend doesn’t sanitize this, you might trigger an unhandled parsing exception.

The Golden Rule: Never trust a text box that claims it “only accepts numbers.” Prove it.