Reputation: 16555
I have some piece of code where is use BigInteger.and operation and I am not sure what is this doing. In javadoc is written bigIng & bigInt but this doesn help me to. Can someone explain me in this example ?
512.and(113078212145816597093331040047546785012958969400039613319782796882727665664)
Upvotes: 1
Views: 355
Reputation: 692231
&
in Java is the bitwise and operator. See http://docs.oracle.com/javase/tutorial/java/nutsandbolts/op3.html for explanations.
1 & 1 == 1
0 & 1 == 0
1 & 0 == 0
0 & 0 == 0
Upvotes: 0
Reputation: 727077
The and
operation returns the result of performing bitwise and on binary representations of two big integers. In your particular example, bit number ten is extracted, because the binary representation of 512 is 1000000000
.
Upvotes: 2