
上QQ阅读APP看书,第一时间看更新
and
The and function compares the corresponding bits of two values. If either of the two bits is 0, it gives 0, if not and both bits are 1, it gives 1.
Consider this example:
fun main(args: Array<String>) {
val a=2
val b=3
print(a and b)
}
This is the output:
2
Let's look at the explanation:
2 = 10 (Binary format)
3 = 11 (Binary format)
Bitwise AND of 2 and 3
in binary
10 AND 11
10 = 2 (Decimal format)