Bitwise AND operator & - IBM

文章推薦指數: 80 %
投票人數:10人

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



請為這篇文章評分?