Programming in C
280 Chapter 12 Operations on Bits To convert a negative number from binary back to decimal, first complement all of the bits, co ...
Bit Operators 281 The Bitwise AND Operator When two values are ANDed in C, the binary representations of the values are com- par ...
282 Chapter 12 Operations on Bits When using constants in performing bitwise operations, it is usually more convenient to expres ...
Bit Operators 283 The second printfcall results in the display of octal 77 ,which is the result of ANDing word1with itself. By d ...
284 Chapter 12 Operations on Bits Bitwise Inclusive-ORing, frequently called just bitwise ORing, is used to set some specified b ...
Bit Operators 285 Using the Exclusive-OR operator, you can exchange values without the need of the temporary storage location: i ...
286 Chapter 12 Operations on Bits w1gets ANDed with the correct value on any machine because the ones complement of 1 is calcula ...
Bit Operators 287 You should work out each of the operations from Program 12.2 with a paper and pencil to verify that you unders ...
288 Chapter 12 Operations on Bits high-order bits.What is shifted in on the left for signed values depends on the sign of the va ...
Bit Operators 289 unsigned int shift (unsigned int value, int n) { if ( n > 0 ) // left shift value <<= n; else // righ ...
290 Chapter 12 Operations on Bits In the third call to shift,a shift count of zero is specified. In this case, the shift func- t ...
Bit Operators 291 printf ("%x\n", rotate (w1, 8)); printf ("%x\n", rotate (w1, -16)); printf ("%x\n", rotate (w2, 4)); printf (" ...
292 Chapter 12 Operations on Bits bfffc448 abcdef00 def00abc The function first ensures that the shift count,n, is valid.The cod ...
Bit Fields 293 that contain packed information. Just as a short intcan be used to conserve memory space on some computers, so ca ...
294 Chapter 12 Operations on Bits or you can set the typefield to the value n, where nis between 0 and 255 ,by the statement pac ...
Bit Fields 295 The structure packed_structis defined to contain six members.The first member is not named.The :3specifies three ...
296 Chapter 12 Operations on Bits unsigned int f2:1; unsigned int f1:1; unsigned int :3; }; to achieve the same representation o ...
Exercises 297 Exercises Type in and run the four programs presented in this chapter. Compare the output produced by each progra ...
298 Chapter 12 Operations on Bits at 0 with the leftmost bit, extract the specified number of bits from the first argu- ment and ...
13 The Preprocessor 13 The Preprocessor THIS CHAPTER DESCRIBES YET ANOTHER UNIQUE FEATUREof the C language that is not found in ...
«
11
12
13
14
15
16
17
18
19
20
»
Free download pdf