Bitwise operators manipulate individual bits within an integer value, comparing 1 and 0 values at a binary level. Use the & operator to test when both bits are 1, the | operator expression when either bit is 1, the ^ operator expression when both bits are different, and the ~ operator to reverse bits, changing 1 to 0 and 0 to 1.
- [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 lines 23 and 24. … Build and run the code to get a visual representation …
- Writing your first C program
- Working the C development cycle
- Adding comments to code for clarity
- C language data types
- Declaring variables
- Making new data types
- Typecasting variables
- Using math, assignment, and logical operators
- Creating for and while loops
- Nesting loops
- Creating functions
- Returning values from functions
- Passing arguments to functions
- Creating recursive functions
Skill Level Intermediate
C: Data Structures, Pointers, and File Systemswith Dan Gookin2h 57m Intermediate
1. The Fundamentals of C
2. Variables and Values
3. Operators and Math
4. Decisions and Loops
Next steps1m 38s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.