I'm beeing introduced to bitwise operators and I know that it performs a certain operation in each bit of a variable.
Can I ensure that this variable will contain only the value 3 using any bitwise operation?
// if i==3: ((0) + 3) & 3 == 0b11 & 0b11 == 0b11
int mod3 = ((i % 3) + 3) & 3;
Testing:
int mod3 = (5) & 3 //0b101 & 0b011 == 0b001 -> mod3 == 1?
impressive