Bitwise AND operator & - IBM
文章推薦指數: 80 %
The & (bitwise AND) operator compares each bit of its first operand to the corresponding bit of the second operand. If both bits are 1 's, the corresponding ... BitwiseANDoperator& The&(bitwiseAND)operatorcompareseachbitofitsfirst operandtothecorrespondingbitofthesecondoperand.Ifbothbitsare1's,thecorrespondingbitoftheresultissetto1.Otherwise, itsetsthecorrespondingresultbitto0. Bothoperandsmusthaveanintegralorenumerationtype.Theusualarithmetic conversionsoneachoperandareperformed.Theresulthasthesametypeas theconvertedoperands. BecausethebitwiseANDoperatorhasbothassociativeandcommutativeproperties, thecompilercanrearrangetheoperandsinanexpressionthatcontainsmore thanonebitwiseANDoperator. Thefollowingexampleshowsthevaluesofa,b,and theresultofa & brepresentedas16-bitbinarynumbers: bitpatternofa 0000000001011100 bitpatternofb 0000000000101110 bitpatternofa&b 0000000000001100 Note:ThebitwiseAND(&)shouldnotbeconfused withthelogicalAND.(&&)operator.Forexample, 1&4evaluatesto0 while 1&&4evaluatestotrue Parenttopic:Binaryexpressions
延伸文章資訊
- 1Bitwise Operators in C/C++ - GeeksforGeeks
The | (bitwise OR) in C or C++ takes two numbers as operands and does OR on every bit of two numb...
- 2Bitwise AND (&) - JavaScript - MDN Web Docs
The bitwise AND operator ( & ) returns a 1 in each bit position for which the corresponding bits ...
- 3Bitwise AND operator & - IBM
The & (bitwise AND) operator compares each bit of its first operand to the corresponding bit of t...
- 4你所不知道的C 語言:bitwise 操作 - HackMD
複習數值系統,從應用案例引導學員掌握bitwise 操作,從而邁向專業的程式開發.
- 5Bitwise Operators in C Programming - Programiz
Bitwise AND operator &. The output of bitwise AND is 1 if the corresponding bits of two operands ...