July 2018
Intermediate to advanced
400 pages
12h 14m
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:
Integer.toBinaryString(42)
101010
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, such as Java. Table 8.2 shows commonly used binary operations available in Kotlin.
Table 8.2 Binary operations
| Function | Description | Example |
|---|---|---|
| Integer.toBinaryString | Converts an integer to binary representation. |
Integer.toBinaryString(42) ... |
Read now
Unlock full access