DMP - Chapter 15


Bit Fiddling

Signed integers

Octal (e.g. 0377 == 1111111)

Hexadecimal

Bitwise operators: ~, &, |, ^

Masks (&);

Bit on (| MASK), off (| -MASK)

Toggling bits (^ MASK)

Structure contents in a file

Checking the value of a bit (flag & MASK) == MASK

Bitwise shift operators (<<, >>)

Bit fields

struct
{
unsigned bit1: 1;
unsigned bits: 4;
unsigned bit3: 2;
} flag;

Assignment #14 (Due 21 Jan. 1997):


Go to Ich's Home Page
Go to the Peabody Home Page
For comments or questions email to: ich@peabody.jhu.edu