Until now we have dealt with various operators. All these operators are operated on constants and variables of different data types, i.e., they are operated on byte level. But we are not able to get scope to see within these data types that how they are actually constructed with the individual bits. Also we are not able to set the individual bits within the bytes. If we write int x = 5; we know that the binary equivalent of 5, i.e., 101 will be stored in some memory location named x. As it is an integer variable it occupies 2 bytes of memory. So the total bit pattern of it will be 00000000 00000101. We know it but are never able to test that whether it is the actual bit pattern or not. This is an example but it was not possible for us to check or set the individual bit. But bit level operation is very important when a program interacts directly with the hardware. In this chapter, we will learn about bit by bit manipulation.
Another important feature of C language is it provides a set of operators that operate on individual bits of a variable. They are known as bitwise operators. Apart from hardware interaction these operators help us to save memory and make some computation faster. But these operators can only be applied to integral operands, i.e., integer and character operands, whether signed or unsigned.
Review the options below to login to check your access.
Log in with your Cambridge Aspire website account to check access.
If you believe you should have access to this content, please contact your institutional librarian or consult our FAQ page for further information about accessing our content.