From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Understanding bitwise operators - C Tutorial
From the course: Complete Guide to C Programming Foundations
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 video are Bitwise AND:&, Bitwise Inclusive OR: |, Bitwise Exclusive OR: ^, and the One's compliment:~. Be aware that the carrot or hat character is the Bitwise exclusive OR operator. In many programming languages, this is the power or exponentiation 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 the exercise files called binString. It takes an integer value as input and returns a string of ones and zeros to represent bits in a value. The main function demonstrates the Bitwise AND Operator at line 28. Like its logical operator counterpart, the Bitwise AND test is true only when both bits at the same position in a value are set, or they're equal to one. The hexa decimal values tested or assigned lines 23 and 24. Run the program…
Contents
-
-
-
-
-
Working with math operators3m 13s
-
(Locked)
Challenge: Do some math50s
-
(Locked)
Solution: Do some math1m 47s
-
(Locked)
Using assignment operators1m 49s
-
(Locked)
Obeying the order of precedence3m 14s
-
(Locked)
Challenge: Get the order correct55s
-
(Locked)
Solution: Get the order correct1m 37s
-
(Locked)
Working with relational operators3m 48s
-
(Locked)
Using logical operators3m 58s
-
(Locked)
Understanding bitwise operators3m 44s
-
(Locked)
Shifting bits3m 13s
-
(Locked)
Exploring unary operators3m 3s
-
Chapter challenge: More math1m 8s
-
(Locked)
Chapter solution: More math2m 45s
-
-
-
-
-
-
-
-
-