Skip to main content Accessibility help
×
Hostname: page-component-6bb9c88b65-znhjv Total loading time: 0 Render date: 2025-07-27T09:52:55.671Z Has data issue: false hasContentIssue false

17 - Bitwise Operators

Published online by Cambridge University Press:  17 July 2025

Subrata Saha
Affiliation:
Techno India Hooghly, West Bengal
Subhodip Mukherjee
Affiliation:
Techno India College of Technology, West Bengal
Get access

Summary

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.

Information

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2016

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Book purchase

Temporarily unavailable

Accessibility standard: Unknown

Accessibility compliance for the PDF of this book is currently unknown and may be updated in the future.

Save book to Kindle

To save this book to your Kindle, first ensure no-reply@cambridge-org.demo.remotlog.com is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×