Comparing values
The ways that you can compare values depends on the types of those values.
Many types allow the usual comparison operators: =, !=, <, >, ≤ and ≥.
The syntax depends on the language.
Comparing values in this way produces a Boolean type that you can use in conditional instructions or to continue or terminate loops.
How values are compared depends on the type of the values:
nat,int,mutezand timestamp values are compared numerically.- Strings, 
bytes,key_hash,key,signatureandchain_idvalues are compared lexicographically. - Boolean values are compared so that false is strictly less than true.
 - Address are compared as follows:
- Addresses of user accounts are strictly less than addresses of smart contracts.
 - Addresses of the same type are compared lexicographically.
 
 - Pair values (and therefore records) are compared component by component, starting with the first component.
 - Options are compared as follows:
Noneis strictly less than anySome.Some xandSome yare compared asxandy.
 - Values of 
uniontypes built withorare compared as follows:- any 
Left xis smaller than anyRight y, Left xandLeft yare compared asxandy,Right xandRight yare compared asxandy.
 - any 
 - Values of type 
Unitare all equal. 
In Michelson, comparisons are done in two steps:
- A 
COMPAREinstruction consumes the values and produces a value that is 0 if the two elements are equal, negative if the first element in the stack is less than the second, and positive otherwise. - The instructions 
EQ(equal),NEQ(not equal),LT(lower than),GT(greater than),LE(lower or equal) andGE(greater or equal) consume this value and return the corresponding Boolean value. 
Implementation details
- Michelson: Generic comparison
 - Archetype: Comparison operators
 - SmartPy: Comparing sp.int and sp.nat
 - LIGO: Comparing values