Skip to main content Accessibility help
Internet Explorer 11 is being discontinued by Microsoft in August 2021. If you have difficulties viewing the site on Internet Explorer 11 we recommend using a different browser such as Microsoft Edge, Google Chrome, Apple Safari or Mozilla Firefox.

Chapter 17: Bitwise Operators

Chapter 17: Bitwise Operators

pp. 507-527

Authors

, Techno India Hooghly, West Bengal, , Techno India College of Technology, West Bengal
  • Add bookmark
  • Cite
  • Share

Extract

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.

About the book

Access options

Review the options below to login to check your access.

Purchase options

Paperback
US$105.00

Have an access code?

To redeem an access code, please log in with your personal login.

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.

Also available to purchase from these educational ebook suppliers