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:
This page is posted |
http://mindprod.com/jgloss/andoperator.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\andoperator.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[3.141.32.53] |
| |
Feedback |
You are visitor number | |