You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
493 B
C

#include <assert.h>
int main() {
int foo;
foo = 42;
/* Delete bit 5 */
foo &= ~(1 << 5);
assert(foo == 10);
foo &= ~(1 << 5);
assert(foo == 10);
/* Set bit 5 again */
foo |= (1 << 5);
assert(foo == 42);
foo |= (1 << 5);
assert(foo == 42);
/* Set bit 0 */
foo |= (1 << 0);
assert(foo == 43);
/* Delete bit 0 */
foo &= ~(1 << 0);
assert(foo == 42);
/* Toggle bit 5 */
foo ^= (1 << 5);
assert(foo == 10);
foo ^= (1 << 5);
assert(foo == 42);
}