December 2014
Beginner
300 pages
8h 9m
English
Bitwise AND is represented by a single ampersand: &. Whereas bitwise NOT inverts all the bits, bitwise AND changes the bits only if both bits are 1s. For example, say that you have something like what’s shown in Figure 7.3.
Figure 7.3 Performing a bitwise AND on two bytes.
In this example, the result of the bitwise AND combination is 0 because there is no place where both bit 1 and bit 2 contain 1s in the same slot. You could code this example like so:
var a:UInt8 = 0b10101010 //170var b:UInt8 = 0b01010101 //85a&b //0
Figure 7.4 shows another example of a bitwise AND combination that has some positive ...
Read now
Unlock full access