0b0101_0101 & 0b0001_1100 → 0b0001_0100
& logical AND is a logical carryless bitwise multiply, used for masking (getting rid of parts of a word you don’t want), 1s where both operands have a 1 otherwise 0. Don’t confuse this with &&.
0 & 0 →
0
0 & 1 →
0
1 & 0 →
0
1 & 1 →
1
boolean isPowerOfTwo = (n & -n) == n;
Here is how to and together an array of booleans:
|
|
available on the web at: |
http://mindprod.com/jgloss/andoperator.html |
optional Replicator mirror
|
J:\mindprod\jgloss\andoperator.html | |
![]() |
Please email your
feedback for publication,
letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear
wording, broken/redirected link reports, suggestions to improve this page or comments to
Roedy Green :
| |
| Blog | Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[184.73.7.143] |
|
| Feedback | You are visitor number 11. | |