课程: Complete Guide to C Programming Foundations

今天就学习课程吧!

今天就开通帐号,24,100 门业界名师课程任您挑!

Understanding bitwise operators

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…

内容