July 2018
Intermediate to advanced
400 pages
12h 14m
English
All numeric types in Kotlin, as in Java, are signed, meaning they can represent both positive and negative numbers. In addition to whether they support decimal values, the numeric types differ in the number of bits they are allocated in memory and, consequently, their minimum and maximum values.
Table 8.1 shows some of the numeric types in Kotlin, the number of bits for each type, and the maximum and minimum value the type supports. (We will explain these details in a moment.)
Table 8.1 Commonly used numeric types
| Type | Bits | Max Value | Min Value |
|---|---|---|---|
| Byte | 8 | 127 | -128 |
| Short | 16 | 32767 | -32768 |
| Int | 32 | 2147483647 | -2147483648 |
| Long | 64 | 9223372036854775807 | -9223372036854775808 ... |
Read now
Unlock full access