Given a Double
val double = 1.2345
How can I convert that to a Kotlin ByteArray
, and/or Array<Byte>
?
Whose content would look like the following after converting 1.2345
00111111 11110011 11000000 10000011
00010010 01101110 10010111 10001101
In Java, there is a sollution that involves Double.doubleToLongBits()
(A static method of java.lang.Double), but in Kotlin, Double refers to Kotlin.Double
, which has no such (or any other useful in this situation) method.
I don't mind if a sollution yields Kotlin.Double
inaccessible in this file. :)