A lot of coding problems on various platforms ask about identifying if a number is odd or even. The programming languages provide a convenient module operator(%) which people usually use. However, modulus operator is expensive it involves division(successive subtraction) and it is not performant.
If the requirement is just to identify if a number is even or odd, bitwise operator AND can be used for this purpose.
A lot of coding problems on various platforms ask about identifying if a number is odd or even. The programming languages provide a convenient module operator(%) which people usually use. However, modulus operator is expensive it involves division(successive subtraction) and it is not performant.
If the requirement is just to identify if a number is even or odd, bitwise operator AND can be used for this purpose.