Skip to main content
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: 0x14 Introduced: Frontier (EVM genesis) EQ performs bitwise equality comparison on two 256-bit values. Returns 1 if the values are exactly equal, 0 otherwise. This is a fundamental operation for implementing conditional logic, address validation, and state checks. Unlike comparison operations (LT/GT), EQ works identically for both signed and unsigned interpretations since it performs exact bitwise equality.

Specification

Stack Input:
Stack Output:
Gas Cost: 3 (GasFastestStep) Operation:

Behavior

EQ pops two values from the stack, compares them bitwise, and pushes 1 if they are exactly equal, otherwise 0:
  • If a == b (all 256 bits identical): Result is 1 (true)
  • If a != b (any bit differs): Result is 0 (false)
Comparison is bitwise - no interpretation as signed/unsigned is needed.

Examples

Basic Equality

Inequality

Zero Equality

Maximum Value

Address Comparison

Sign-Independent

Gas Cost

Cost: 3 gas (GasFastestStep) EQ shares the lowest gas tier with all comparison operations:
  • LT, GT, SLT, SGT, EQ (comparisons)
  • ISZERO, NOT
  • ADD, SUB
Comparison:
  • EQ: 3 gas
  • LT/GT: 3 gas
  • MUL/DIV: 5 gas

Edge Cases

Identical Values

Different Values

Large Values

Stack Underflow

Out of Gas

Common Usage

Address Validation

State Checks

Conditional Execution

Enum Comparison

Hash Verification

Implementation

Testing

Test Coverage

Edge Cases Tested

  • Equal values (42 == 42)
  • Unequal values (10 != 20)
  • Zero equality (0 == 0)
  • Zero inequality (0 != 1)
  • Maximum value equality
  • Large value comparison
  • Stack underflow (< 2 items)
  • Out of gas (< 3 gas)
  • Stack preservation

Security

Zero Address Checks

CRITICAL: Always validate addresses are not zero:

Access Control

State Validation

Hash Comparison

Optimizations

Commutative Property

Zero Check Pattern

Inverted Logic

Multiple Comparisons

Benchmarks

EQ is one of the fastest EVM operations: Execution time (relative):
  • EQ: 1.0x (baseline)
  • LT/GT: 1.0x
  • ISZERO: 0.95x
  • ADD: 1.0x
  • MUL: 1.5x
Gas efficiency:
  • 3 gas per equality check
  • ~333,333 comparisons per million gas
  • Highly optimized in all EVM implementations

References

  • ISZERO - Zero check (specialized EQ)
  • LT - Less than (unsigned)
  • GT - Greater than (unsigned)
  • SLT - Signed less than
  • SGT - Signed greater than