January 2018
Intermediate to advanced
434 pages
14h 1m
English
The ushr function shifts the bit pattern to the right by the specified number of bits, filling the leftmost with 0s.
Here's an example:
fun main(args: Array<String>) { println( 5 ushr 0) println( 5 ushr 1) println( 5 ushr 2)}
This will output the following:
521
This is its 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