Does Kotlin offer a way to describe a 'whole number' such as Int
, Long
or BigInteger
but not Double
?
In Kotlin, as in Java, there is Number
as the supertype of all numerical types including the floating-point numbers. Java does not let you exclude the floating-points, as the oracle docs about the numerical types state that they directly subclass the abstract class Number
and implement no Interfaces (except Comparable and Serializable).
In the Kotlin-documentation, I could not find any such whole-number-type, but I did not find any definitive List of numerical types or a statement that says such a whole-number-type was purposefully not included.
There is no such type.
Looking into the source-code of Kotlin we can see that the type-hierarchy of numbers is exactly the same as in Java: All number-types directly subclass Number
and implement no interface that would describe them further.
https://github.com/JetBrains/kotlin/blob/master/core/builtins/native/kotlin/Primitives.kt