Pages

Tuesday, June 4, 2024

Toggle a bit in C using XOR

  


int number= 0b11001100;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
number ^= 1 << 2;
delay(100);
Serial.println(number,BIN);

}



since we count from zero the 3rd last bit will toggle









No comments:

Post a Comment

What is anti- Debugging

  Anti- debugging is how we can stop somebody from debugging our system and getting all the information out of your subsystem.