Faster operation to find even or odd

which is faster num % 2 or num & 1 to check whether the number is odd or even?? Please give the reason also…

hello @govilayush

second one is faster ie num&1 becuase it is bitwise operation all bitwise operations are faster than any arithmentic operations

why bitwise operation is faster??

@govilayush
bitwise operations work on bits whereas arithmentic operator work on set of bit ( a decimal number is set of bit) so it is very obvious that bit operation will be little fast

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.