January 2018
Intermediate to advanced
434 pages
14h 1m
English
The inv function simply inverts the bit patterns. If the bit is 1, it makes it 0 and vice versa.
Here's an example:
fun main(args: Array<String>) { val a=2 print(a.inv())}
This is the output:
-3
The following is the explanation:
2 = 10 (Binary format)
Bitwise complement of 2 = 01, but the compiler shows 2’s complement of that number, which is the negative notation of the binary number.
2’s complement of an integer n is equal to -(n+1).
Read now
Unlock full access