Is the inequality operator faster than the equality operator?

Mackenzie picture Mackenzie · Jun 23, 2009 · Viewed 26.4k times · Source

I know this is a micro-optimization, so I ask out of pure curiosity.

Logically, a microprocessor does not need to compare all the bits of both operands of an equality operator in order to determine a "FALSE" result.

Note, this is programming-related because it affects the execution speed of a program.

Answer

mmx picture mmx · Jun 23, 2009

Usually, the microprocessor does comparison using electrical gates and not step by step like that. It checks all bits at once.