
Everyday Problems 59
Program 41: A Bit of Trouble
The
bit_out
goes through a 16-bit value printing out the value of each bit. It gen-
erates a graphical representation of the work, but the output looks a little
strange. What’s happening?
1 /************************************************
2 * bit test -- Test the routine to print out *
3 * the bits in a flag. *
4 ************************************************/
5 #include <iostream>
6 /************************************************
7 * bit_out -- print a graphical *
8 * representation of each bit in a *
9 * 16 bit word. *
10 * *
11 * For example: *
12 * 0x55AF will print -X-X-X-XX-X-XXXX *
13 ********** ...