October 2021
Intermediate to advanced
500 pages
16h 23m
English
Earlier, you saw that numbers have a binary representation. You can get the binary representation for a number at any time. For example, you could ask for the binary representation of the integer 42 with:
42.toString(radix = 2)
"101010"
(The radix parameter indicates the desired base of the outputted number.
By specifying 2, you request a number in base 2, or binary.
The default radix is 10, which outputs a decimal number.
Another commonly used radix is 16, which returns a hexadecimal string.)
Kotlin includes functions for performing operations on the binary representation of a value, called bitwise operations – including operations you may be familiar with from other languages, ...
Read now
Unlock full access