Beruflich Dokumente
Kultur Dokumente
Objectives
To be able to use the bitwise logical operators in programs To be able to use the bitwise shift operators in programs To understand how to create and use masks to manipulate bits
Table 14-1
Table 14-2
10
Table 14-4
11
PROGRAM 14-3
12
PROGRAM 14-3
13
14
PROGRAM 14-4
Ones Complement
15
PROGRAM 14-4
Ones Complement
16
PROGRAM 14-5
Demonstrate Checksum
18
PROGRAM 14-5
Demonstrate Checksum
19
22
23
24
Table 14-6
Divide by Shift
25
PROGRAM 14-7
27
PROGRAM 14-7
28
Table 14-7
Multiply by Shift
29
31
32
33
14-4 Masks
In many programs, bits are used as binary flags: 0 is off, and 1 is on. To set and test the flags, we use a bit mask. A mask is a variable or constant, usually stored in a byte or short integer. The bits are numbered from the least significant bit (rightmost), starting at 0.
36
37
38
39
PROGRAM 14-10
40
PROGRAM 14-10
41
PROGRAM 14-10
42
PROGRAM 14-10
43
46
47
48
49
50
Note
Good programs start with a good structure chart design.
54
Table 14-8