This page is a placeholder. All examples on this page are currently AI-generated and are not correct. This documentation will be completed in the future with accurate, tested examples.
Overview
Opcode: 0x10
Introduced: Frontier (EVM genesis)
LT performs unsigned less than comparison on two 256-bit integers. Returns 1 if the first value is strictly less than the second, 0 otherwise. All values are treated as unsigned integers in the range 0 to 2^256 - 1.
This is the fundamental comparison operation for implementing conditional logic and bounds checking in smart contracts.
Specification
Stack Input:
Stack Output:
Gas Cost: 3 (GasFastestStep)
Operation:
Behavior
LT pops two values from the stack, compares them as unsigned 256-bit integers, and pushes 1 if a < b, otherwise 0:
- If
a < b: Result is 1 (true)
- If
a >= b: Result is 0 (false)
All comparisons are unsigned. Values with bit 255 set are treated as large positive numbers, not negative values.
Examples
Basic Comparison
Equal Values
Greater Value
Zero Comparison
Maximum Values
Unsigned Treatment
Gas Cost
Cost: 3 gas (GasFastestStep)
LT shares the lowest gas tier with other comparison and basic operations:
- LT, GT, SLT, SGT, EQ (comparisons)
- ISZERO, NOT
- ADD, SUB
Comparison:
- LT/GT/EQ: 3 gas
- MUL/DIV: 5 gas
- ADDMOD: 8 gas
Edge Cases
Boundary Values
Sign Bit Set
Stack Underflow
Out of Gas
Large Values
Common Usage
Bounds Checking
Range Validation
Loop Conditions
Minimum Value
Array Access Safety
Implementation
Testing
Test Coverage
Edge Cases Tested
- Basic comparisons (a < b, a = b, a > b)
- Zero comparisons (0 < 1, 1 < 0)
- Maximum values (MAX-1 < MAX)
- Unsigned treatment (sign bit set)
- Stack underflow (< 2 items)
- Out of gas (< 3 gas)
- Large arbitrary values
- Stack preservation
Security
Unsigned vs Signed Confusion
CRITICAL: LT treats all values as unsigned. Do not use for signed integer comparisons:
Off-by-One Errors
Integer Overflow Before Comparison
Type Width Issues
Optimizations
Inversion Patterns
Short-Circuit Evaluation
Constant Comparison
Benchmarks
LT is one of the fastest EVM operations:
Execution time (relative):
- LT: 1.0x (baseline)
- GT/EQ: 1.0x
- ISZERO: 0.95x
- ADD: 1.0x
- MUL: 1.5x
Gas efficiency:
- 3 gas per comparison
- ~333,333 comparisons per million gas
- Highly optimized in all EVM implementations
References
- GT - Greater than (unsigned)
- SLT - Signed less than
- SGT - Signed greater than
- EQ - Equality check
- ISZERO - Zero check