https://kotlinlang.org logo
h

Hassaan

08/27/2022, 3:36 PM
while converting the Double value to Long, is type overflow possible?
e

ephemient

08/27/2022, 6:16 PM
yes.
1e19.toLong()
gets truncated to
Long.MAX_VALUE
h

Hassaan

09/01/2022, 10:58 AM
Truncation is not overflow but i got the point thank u. The fractional part, if any, is rounded down towards zero. Returns zero if this
Double
value is
NaN
, Long.MIN_VALUE if it’s less than
Long.MIN_VALUE
, Long.MAX_VALUE if it’s bigger than
Long.MAX_VALUE
4 Views