January 2018
Intermediate to advanced
434 pages
14h 1m
English
The shr function shifts the bit pattern to the right by the specified number of bits.
Take this example into consideration:
fun main(args: Array<String>) { println( 5 shr 0) println( 5 shr 1) println( 5 shr 2)}
Given here is the output:
521
The following is the explanation:
5 = 101 (Binary format)
101 Shift right by 0 bits = 101
101 Shift right by 1 bits = 010 (2 in Decimal)
101 Shift right by 2 bits = 001 (1 in Decimal)
Read now
Unlock full access