toRawBits

Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
fun Double.toRawBits(): Long

Returns a bit representation of the specified floating-point value as Long according to the IEEE 754 floating-point "double format" bit layout, preserving NaN values exact layout.

Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
fun Float.toRawBits(): Int
For Common, JVM, Native

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout, preserving NaN values exact layout.

For JS

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout, preserving NaN values exact layout.

Note that in Kotlin/JS Float range is wider than "single format" bit layout can represent, so some Float values may overflow, underflow or loose their accuracy after conversion to bits and back.

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/to-raw-bits.html