According to solidity docs the type address has the following operators:

<=, <, ==, !=, >= and >

Besides checking for equality - Why would I want to check if an address is greater or smaller than another one? What is the usecase?

2 Answers 2


An address is a 20 byte number, so it gets comparison operators for free: Solidity doesn't have to implement anything, and the gas costs for using them are the same as comparing integers.

In the future, the comparison operators might be useful depending on how in Ethereum works. For example, one of the simplest and early ideas was to shard according to address space, like shard1 contains the first billion addresses, shard2 contains the next billion, and so on. A contract might then use the comparison operators to determine which shard another contract was in.


They can be used to create things like binary trees which can speed up lookups for collections that are not mapped explicitly, and reduce the number of operations it takes to retrieve a record.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.