-4

To set the lowest bit in an unsigned char I can perform this operation:

my_unsigned_char = my_unsigned_char | 1; 

But how can I turn off this flag?

Spaceghost
  • 6,835
  • 3
  • 28
  • 42
vico
  • 17,051
  • 45
  • 159
  • 315

1 Answers1

2

Use the bitwise not operator:

my_unsigned_char = my_unsigned_char & ~1;
fuz
  • 88,405
  • 25
  • 200
  • 352