0x07fff=0111111111111111 What will happen if you do and operate this thing? The first bit is 0, and the other bits remain unchanged.
Depending on the data type, the higher bit in the signed data type represents the symbol. In this case, the AND operation is used to obtain the absolute value, that is, to obtain the useful 15 bits.
Sometimes bitwise search or bitwise operation is relatively faster.
There is another situation where it is used to show off.
0x7fff = 0111 1111 1111 1111 & is an AND operation So this operation is to take the last 15 digits of the binary representation of the number "13634393448"
0x07fff=0111111111111111
What will happen if you do and operate this thing? The first bit is 0, and the other bits remain unchanged.
Depending on the data type, the higher bit in the signed data type represents the symbol. In this case, the AND operation is used to obtain the absolute value, that is, to obtain the useful 15 bits.
Sometimes bitwise search or bitwise operation is relatively faster.
There is another situation where it is used to show off.
String.hashCode()
的返回值计算方式为:s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
你给的13634393448,其hashCode结果是
1002012672
,也就是0x3bb98000
。同
0x7fff
做"与"操作,也就是表示取0x3bb98000
后三位的值,本题的结果自然就是0
.0x7fff = 0111 1111 1111 1111
& is an AND operation
So this operation is to take the last 15 digits of the binary representation of the number "13634393448"
0x Convert to hexadecimal
A single
&
是 按位与操作, 两个&
is the logical AND