WASM: Impelment float to string conversion operations
This commit is contained in:
committed by
TeamCityServer
parent
f34a079699
commit
0eba74a9d2
@@ -7,6 +7,10 @@ package kotlin
|
||||
|
||||
import kotlin.annotation.AnnotationTarget.FIELD
|
||||
import kotlin.annotation.AnnotationTarget.PROPERTY
|
||||
import kotlin.wasm.internal.wasm_f32_reinterpret_i32
|
||||
import kotlin.wasm.internal.wasm_f64_reinterpret_i64
|
||||
import kotlin.wasm.internal.wasm_i32_reinterpret_f32
|
||||
import kotlin.wasm.internal.wasm_i64_reinterpret_f64
|
||||
|
||||
|
||||
/**
|
||||
@@ -27,19 +31,19 @@ public actual fun interface Comparator<T> {
|
||||
|
||||
// From numbers.kt
|
||||
|
||||
actual fun Double.isNaN(): Boolean = TODO("Wasm stdlib: Kotlin")
|
||||
actual fun Float.isNaN(): Boolean = TODO("Wasm stdlib: Kotlin")
|
||||
actual fun Double.isInfinite(): Boolean = TODO("Wasm stdlib: Kotlin")
|
||||
actual fun Float.isInfinite(): Boolean = TODO("Wasm stdlib: Kotlin")
|
||||
actual fun Double.isFinite(): Boolean = TODO("Wasm stdlib: Kotlin")
|
||||
actual fun Float.isFinite(): Boolean = TODO("Wasm stdlib: Kotlin")
|
||||
actual fun Double.isNaN(): Boolean = this != this
|
||||
actual fun Float.isNaN(): Boolean = this != this
|
||||
actual fun Double.isInfinite(): Boolean = (this == Double.POSITIVE_INFINITY) || (this == Double.NEGATIVE_INFINITY)
|
||||
actual fun Float.isInfinite(): Boolean = (this == Float.POSITIVE_INFINITY) || (this == Float.NEGATIVE_INFINITY)
|
||||
actual fun Double.isFinite(): Boolean = !isInfinite() && !isNaN()
|
||||
actual fun Float.isFinite(): Boolean = !isInfinite() && !isNaN()
|
||||
|
||||
/**
|
||||
* 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 actual fun Double.toBits(): Long = TODO("Wasm stdlib: Kotlin")
|
||||
public actual fun Double.toBits(): Long = if (isNaN()) Double.NaN.toRawBits() else toRawBits()
|
||||
|
||||
/**
|
||||
* Returns a bit representation of the specified floating-point value as [Long]
|
||||
@@ -47,20 +51,20 @@ public actual fun Double.toBits(): Long = TODO("Wasm stdlib: Kotlin")
|
||||
* preserving `NaN` values exact layout.
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
public actual fun Double.toRawBits(): Long = TODO("Wasm stdlib: Kotlin")
|
||||
public actual fun Double.toRawBits(): Long = wasm_i64_reinterpret_f64(this)
|
||||
|
||||
/**
|
||||
* Returns the [Double] value corresponding to a given bit representation.
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
public actual fun Double.Companion.fromBits(bits: Long): Double = TODO("Wasm stdlib: Kotlin")
|
||||
public actual fun Double.Companion.fromBits(bits: Long): Double = wasm_f64_reinterpret_i64(bits)
|
||||
|
||||
/**
|
||||
* 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 actual fun Float.toBits(): Int = TODO("Wasm stdlib: Kotlin")
|
||||
public actual fun Float.toBits(): Int = if (isNaN()) Float.NaN.toRawBits() else toRawBits()
|
||||
|
||||
/**
|
||||
* Returns a bit representation of the specified floating-point value as [Int]
|
||||
@@ -68,13 +72,13 @@ public actual fun Float.toBits(): Int = TODO("Wasm stdlib: Kotlin")
|
||||
* preserving `NaN` values exact layout.
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
public actual fun Float.toRawBits(): Int = TODO("Wasm stdlib: Kotlin")
|
||||
public actual fun Float.toRawBits(): Int = wasm_i32_reinterpret_f32(this)
|
||||
|
||||
/**
|
||||
* Returns the [Float] value corresponding to a given bit representation.
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
public actual fun Float.Companion.fromBits(bits: Int): Float = TODO("Wasm stdlib: Kotlin")
|
||||
public actual fun Float.Companion.fromBits(bits: Int): Float = wasm_f32_reinterpret_i32(bits)
|
||||
|
||||
|
||||
// From concurrent.kt
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
package kotlin
|
||||
|
||||
import kotlin.wasm.internal.*
|
||||
|
||||
/**
|
||||
* Counts the number of set bits in the binary representation of this [Int] number.
|
||||
*/
|
||||
@@ -17,7 +19,7 @@ public actual fun Int.countOneBits(): Int = TODO("Wasm stdlib: Numbers")
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalStdlibApi
|
||||
public actual fun Int.countLeadingZeroBits(): Int = TODO("Wasm stdlib: Numbers")
|
||||
public actual fun Int.countLeadingZeroBits(): Int = wasm_i32_clz(this)
|
||||
|
||||
/**
|
||||
* Counts the number of consecutive least significant bits that are zero in the binary representation of this [Int] number.
|
||||
@@ -84,7 +86,7 @@ public actual fun Long.countOneBits(): Int = TODO("Wasm stdlib: Numbers")
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalStdlibApi
|
||||
public actual fun Long.countLeadingZeroBits(): Int = TODO("Wasm stdlib: Numbers")
|
||||
public actual fun Long.countLeadingZeroBits(): Int = wasm_i64_clz(this).toInt()
|
||||
|
||||
/**
|
||||
* Counts the number of consecutive least significant bits that are zero in the binary representation of this [Long] number.
|
||||
|
||||
Reference in New Issue
Block a user