Skip to main content

Integer Overflow Demo

Visualize how integer overflow behaves in pre-0.8 (silent wraparound) vs 0.8+ Solidity (auto-revert).

Quick Scenarios
Configuration
Integer Type
Operation
Value A
Value B
Number Wheel
uint8 range
0641281920uint8

Value wrapped around the wheel!

OVERFLOW — Silent Wraparound!
255 + 1 = 0
uint8 | Solidity < 0.8.0
True Mathematical Result
256
Exceeds max (255)
Solidity Result (Wrapped)
0
DANGER: The true result (256) exceeds the uint8 range. Pre-0.8 Solidity silently wraps to 0. No error. No revert. The contract continues with the wrong value — this is how exploits happen.
Binary View
Binary (8 bits shown):
A
11111111
= 255
+
Raw
000100000000
overflow bits!
=
00000000
= 0
Value A (hex)
0xff
Value B (hex)
0x01
Result (hex)
0x00
What is Integer Overflow?

When an arithmetic result exceeds the maximum value a type can hold, it wraps around to 0 (unsigned) or flips sign (signed). Pre-0.8 Solidity did this silently.

Why Was It Dangerous?

Silent overflow let attackers bypass balance checks. uint256(0) - 1 = max uint256, making any balance check pass. Over $1B in exploits in 2018 alone.

How 0.8+ Fixes It

Solidity 0.8+ auto-reverts with Panic(0x11) on overflow. No SafeMath needed. Use unchecked {} blocks only when overflow is mathematically impossible.

Did You Know?

uint256 max = 2²⁵⁶ - 1 ≈ 1.15 × 10⁷⁷. Even this enormous number can overflow with multiplication.

Previous: Reentrancy Simulator
Back to reentrancy simulator