6 Mind-Blowing Uses Of Bitwise Operations That You Probably Never Knew Existed
Become An Efficient Engineer With These Use Cases
1. Checking If A Number Is Odd Or Even (Parity)
The conventional way to check if a given number is odd or even is to check the remainder when the number is divided by 2.
If the remainder is 0, the number is even.
If it is not, the number is odd.
def check_parity(num):
if num % 2 == 0:
print("The number i…
Keep reading with a 7-day free trial
Subscribe to Into AI to keep reading this post and get 7 days of free access to the full post archives.