Add SIZE_BITS and SIZE_BYTES constants to Double and Float

#KT-29182
This commit is contained in:
Ilya Gorbunov
2019-10-08 19:42:42 +03:00
parent 1c93911279
commit f3fc1197ae
6 changed files with 72 additions and 3 deletions
+4 -3
View File
@@ -100,18 +100,19 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
*/
public const val MAX_VALUE: $className = $maxValue""")
}
if (kind.isIntegral) {
if (kind.isIntegral || kind.isFloatingPoint) {
val sizeSince = if (kind.isFloatingPoint) "1.4" else "1.3"
out.println("""
/**
* The number of bytes used to represent an instance of $className in a binary form.
*/
@SinceKotlin("1.3")
@SinceKotlin("$sizeSince")
public const val SIZE_BYTES: Int = ${kind.byteSize}
/**
* The number of bits used to represent an instance of $className in a binary form.
*/
@SinceKotlin("1.3")
@SinceKotlin("$sizeSince")
public const val SIZE_BITS: Int = ${kind.bitSize}""")
}
out.println(""" }""")