Numeric Types
Kotlin supports several numeric types. Regardless of which platform you target, the rules for these numeric types stay the same. As of Kotlin 1.5, numeric types in Kotlin come in two flavors: signed and unsigned. Signed numbers can represent both positive and negative numbers. Unsigned numbers can only represent positive numbers. We will discuss signed numbers first and come back to their unsigned counterparts in the section called For the More Curious: Unsigned Numbers near the end of this chapter.
In addition to whether a number has a sign, there are several key differences between Kotlin’s numeric types. Numeric types primarily differ in the number of bits they are allocated in memory and, consequently, their minimum ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access