The same word bits can be interpreted as signed or unsigned.
LET’S PICTURE IT
One printed bit pattern can follow different reading conventions.
SEE IT FOR YOURSELF
Watch a stack machine execute a tiny programStep 1 / 4
The program bytes are PUSH1 02, PUSH1 03, ADD, STOP. The program counter begins at byte zero.
The program bytes are PUSH1 02, PUSH1 03, ADD, STOP. The program counter begins at byte zero.PUSH1 reads its next byte as an immediate value and places two on the stack. The next instruction begins at byte two.The next PUSH1 places three above two. Stack order matters for operations that are not commutative.ADD consumes the top two values and pushes five. The next instruction is STOP at byte five; no storage write is implied by ADD.
Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.
Keep the bits unchanged
Stack words do not carry a signed-type label. Signed operations interpret their words using two’s-complement rules while unsigned operations apply an unsigned interpretation.
Choose the correct comparison
SLT and SGT perform signed comparisons. LT and GT perform unsigned comparisons, so a word representing minus one behaves very differently under the two choices.
Distinguish signed division
SDIV interprets signed operands and truncates toward zero. It has defined boundary behavior that should not be replaced by floating-point host-language arithmetic.
Check operand order
Non-commutative operations require a clear pop order. Confirm which value is first and second under the opcode specification before predicting subtraction or division.
Trace the idea
all-ff word as uint256: 2^256 - 1
all-ff word as int256: -1
SLT and LT can disagree for the same bit patterns.
Stack examples list the bottom first and the top last. These small traces omit gas and surrounding dispatch unless stated.
QUICK CHECK · NO PRESSURE
Does a stack word include a separate signed-type tag?