From the course: C Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Understanding bitwise operators

Understanding bitwise operators - C Tutorial

From the course: C Essential Training

Start my 1-month free trial

Understanding bitwise operators

- [Instructor] The C language has six bitwise operators that work with integer values to manipulate them at the binary level. The four covered in this movie are bitwise AND, bitwise inclusive OR, bitwise exclusive OR, and the one's compliment. Be aware that the caret or hat character is the bitwise exclusive OR operator. In many programming languages, this is the power operator, not so in C, which uses a function to raise a value to a specific power. To demonstrate how these bitwise operators work, I'm using a function in this exercise file called binString. It takes an integer value as input and returns a string of ones and zeros to represent the bits in a byte. The main function demonstrates the bitwise AND at line 28. Like it's logical counterpart, the bitwise AND is a test, and it's only true when both bits at the same position in a value or set are equal to one. The hexadecimal values compared here are assigned at…

Contents