holgerbrandl
11/29/2020, 6:40 PMNumber.toDouble()
"involve rounding" as suggested by its API docs?ephemient
11/29/2020, 6:45 PM>>> (2L shl 53) + 1
res0: kotlin.Long = 18014398509481985
>>> ((2L shl 53) + 1).toDouble().toLong()
res1: kotlin.Long = 18014398509481984
louiscad
11/29/2020, 6:57 PMephemient
11/29/2020, 7:04 PMholgerbrandl
11/29/2020, 7:20 PMNumber
value does not fit into the target type range, so some more details in the Number
API docs would be great.Number
docs state that it may involve rounding or truncation.
which covers range issues. So the docs are somehow correct, although the big odd integers to double example is neither rounding nor truncation, so there is imho some inprecision in the docs.ephemient
11/29/2020, 7:36 PM2.toBigInteger().pow(1024).toDouble() == Double.POSITIVE_INFINITY
holgerbrandl
11/29/2020, 7:42 PM