Add SIZE_BITS and SIZE_BYTES for Double and Float
Make infinities and NaN constant (cherry picked from commit 6c616d845756d9901b52aace4bf61608d7dad399)
This commit is contained in:
committed by
Vasily Levchenko
parent
5c894303e9
commit
b91f3c851c
@@ -23,4 +23,7 @@ internal actual inline fun testOnNonJvm6And7(f: () -> Unit) {
|
||||
}
|
||||
|
||||
actual fun testOnJvm(action: () -> Unit) {}
|
||||
actual fun testOnJs(action: () -> Unit) {}
|
||||
actual fun testOnJs(action: () -> Unit) {}
|
||||
|
||||
|
||||
public actual val isFloat32RangeEnforced: Boolean get() = true
|
||||
|
||||
@@ -1158,18 +1158,31 @@ public final class Float private constructor() : Number(), Comparable<Float> {
|
||||
* A constant holding the positive infinity value of Float.
|
||||
*/
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public val POSITIVE_INFINITY: Float = 1.0f / 0.0f
|
||||
public const val POSITIVE_INFINITY: Float = 1.0f / 0.0f
|
||||
|
||||
/**
|
||||
* A constant holding the negative infinity value of Float.
|
||||
*/
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public val NEGATIVE_INFINITY: Float = -1.0f / 0.0f
|
||||
public const val NEGATIVE_INFINITY: Float = -1.0f / 0.0f
|
||||
|
||||
/**
|
||||
* A constant holding the "not a number" value of Float.
|
||||
*/
|
||||
public val NaN: Float = kotlinx.cinterop.bitsToFloat(0x7fc00000)
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public const val NaN: Float = -(0.0f / 0.0f)
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent an instance of Float in a binary form.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
public const val SIZE_BYTES: Int = 4
|
||||
|
||||
/**
|
||||
* The number of bits used to represent an instance of Float in a binary form.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
public const val SIZE_BITS: Int = 32
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1415,18 +1428,31 @@ public final class Double private constructor() : Number(), Comparable<Double> {
|
||||
* A constant holding the positive infinity value of Double.
|
||||
*/
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public val POSITIVE_INFINITY: Double = 1.0 / 0.0
|
||||
public const val POSITIVE_INFINITY: Double = 1.0 / 0.0
|
||||
|
||||
/**
|
||||
* A constant holding the negative infinity value of Double.
|
||||
*/
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public val NEGATIVE_INFINITY: Double = -1.0 / 0.0
|
||||
public const val NEGATIVE_INFINITY: Double = -1.0 / 0.0
|
||||
|
||||
/**
|
||||
* A constant holding the "not a number" value of Double.
|
||||
*/
|
||||
public val NaN: Double = kotlinx.cinterop.bitsToDouble(0x7ff8000000000000L)
|
||||
@Suppress("DIVISION_BY_ZERO")
|
||||
public const val NaN: Double = -(0.0 / 0.0)
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent an instance of Double in a binary form.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
public const val SIZE_BYTES: Int = 8
|
||||
|
||||
/**
|
||||
* The number of bits used to represent an instance of Double in a binary form.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
public const val SIZE_BITS: Int = 64
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user