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 - C Tutorial
From the course: C Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Working with math operators3m 3s
-
(Locked)
Challenge: Do some math49s
-
(Locked)
Solution: Do some math1m 29s
-
(Locked)
Using assignment operators1m 44s
-
(Locked)
Obeying the order of precedence3m 13s
-
(Locked)
Challenge: Get the order correct54s
-
(Locked)
Solution: Get the order correct1m 11s
-
(Locked)
Working with relational operators3m 39s
-
(Locked)
Using logical operators3m 49s
-
(Locked)
Understanding bitwise operators3m 36s
-
(Locked)
Shifting bits3m 18s
-
(Locked)
Exploring unary operators3m 44s
-
(Locked)
Challenge: Binary math1m 5s
-
(Locked)
Solution: Binary math2m 11s
-
-
-
-