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: 0x11
Introduced: Frontier (EVM genesis)
GT performs unsigned greater than comparison on two 256-bit integers. Returns 1 if the first value is strictly greater than the second, 0 otherwise. All values are treated as unsigned integers in the range 0 to 2^256 - 1.
This operation complements LT for implementing range checks and conditional logic in smart contracts.
Specification
Stack Input:
Stack Output:
Gas Cost: 3 (GasFastestStep)
Operation:
Behavior
GT 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
Lesser Value
Zero Comparison
Maximum Values
Unsigned Treatment
Gas Cost
Cost: 3 gas (GasFastestStep)
GT 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
Upper Bounds Checking
Range Validation
Maximum Value
Countdown Loop
Balance Check
Implementation
Testing
Test Coverage
Edge Cases Tested
- Basic comparisons (a > b, a = b, a < b)
- Zero comparisons (1 > 0, 0 > 1)
- Maximum values (MAX > MAX-1)
- 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: GT treats all values as unsigned. Do not use for signed integer comparisons:
Boundary Conditions
Integer Overflow Before Comparison
Type Confusion
Optimizations
Relationship to LT
Inversion Pattern
Constant Optimization
Benchmarks
GT performance matches LT (both are fastest-tier operations):
Execution time (relative):
- GT: 1.0x (baseline)
- LT/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
- LT - Less than (unsigned)
- SLT - Signed less than
- SGT - Signed greater than
- EQ - Equality check
- ISZERO - Zero check