Quiz Entry - updated: 2026.07.07
How do mathematical integers differ from computer integers?
Math integers are infinite; computer integers use a fixed number of bits, so they have a limited range and can overflow.
* Mathematical integers form an unbounded line while a fixed-width int is a finite ring where incrementing past the maximum wraps back to the minimum. *
Because the bit width is fixed, once a value passes the largest representable number it wraps around instead of continuing to grow — there is simply no room in the bits for a bigger number.
Mathematics:
- Integers: ..., -4, -3, -2, -1, 0, 1, 2, 3, 4, ...
- Infinite range in both directions
Computer abstraction:
int(orlong) represents integersfloat(ordouble) represents real numbers
The problem:
- Computer integers use fixed bits (e.g., 32 bits for
int) - Range is limited: -2,147,483,648 to 2,147,483,647 for 32-bit signed
- Operations can overflow - wrap around or produce wrong results!
Go deeper:
Integer (computer science) (Wikipedia) — fixed-width types, word size, and the finite min/max range that makes machine ints unlike the mathematical set Z.