Provide Double and Float bit conversion functions as extensions in JS and Common
Instance extension: Double/Float.toBits/toRawBits Companion extension: Double/Float.Companion.fromBits #KT-18264 Fixed
This commit is contained in:
@@ -90,6 +90,48 @@ expect fun Float.isInfinite(): Boolean
|
||||
expect fun Double.isFinite(): Boolean
|
||||
expect fun Float.isFinite(): Boolean
|
||||
|
||||
/**
|
||||
* Returns a bit representation of the specified floating-point value as [Long]
|
||||
* according to the IEEE 754 floating-point "double format" bit layout.
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
public expect fun Double.toBits(): 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.
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
public expect fun Double.toRawBits(): Long
|
||||
|
||||
/**
|
||||
* Returns the [Double] value corresponding to a given bit representation.
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
public expect fun Double.Companion.fromBits(bits: Long): Double
|
||||
|
||||
/**
|
||||
* Returns a bit representation of the specified floating-point value as [Int]
|
||||
* according to the IEEE 754 floating-point "single format" bit layout.
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
public expect fun Float.toBits(): Int
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
public expect fun Float.toRawBits(): Int
|
||||
|
||||
/**
|
||||
* Returns the [Float] value corresponding to a given bit representation.
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
public expect fun Float.Companion.fromBits(bits: Int): Float
|
||||
|
||||
|
||||
// From concurrent.kt
|
||||
|
||||
|
||||
Reference in New Issue
Block a user