Introduce SIZE_BYTES and SIZE_BITS constants for all integral types

#KT-8247 Fixed
This commit is contained in:
Ilya Gorbunov
2018-06-28 00:44:05 +03:00
parent 31d7aae98d
commit 0c50014e7a
17 changed files with 288 additions and 16 deletions
@@ -24,6 +24,16 @@ public inline class UByte internal constructor(private val data: Byte) : Compara
* A constant holding the maximum value an instance of UByte can have.
*/
public const val MAX_VALUE: UByte = UByte(-1)
/**
* The number of bytes used to represent an instance of UByte in a binary form.
*/
public const val SIZE_BYTES: Int = 1
/**
* The number of bits used to represent an instance of UByte in a binary form.
*/
public const val SIZE_BITS: Int = 8
}
/**
@@ -24,6 +24,16 @@ public inline class UInt internal constructor(private val data: Int) : Comparabl
* A constant holding the maximum value an instance of UInt can have.
*/
public const val MAX_VALUE: UInt = UInt(-1)
/**
* The number of bytes used to represent an instance of UInt in a binary form.
*/
public const val SIZE_BYTES: Int = 4
/**
* The number of bits used to represent an instance of UInt in a binary form.
*/
public const val SIZE_BITS: Int = 32
}
/**
@@ -24,6 +24,16 @@ public inline class ULong internal constructor(private val data: Long) : Compara
* A constant holding the maximum value an instance of ULong can have.
*/
public const val MAX_VALUE: ULong = ULong(-1)
/**
* The number of bytes used to represent an instance of ULong in a binary form.
*/
public const val SIZE_BYTES: Int = 8
/**
* The number of bits used to represent an instance of ULong in a binary form.
*/
public const val SIZE_BITS: Int = 64
}
/**
@@ -24,6 +24,16 @@ public inline class UShort internal constructor(private val data: Short) : Compa
* A constant holding the maximum value an instance of UShort can have.
*/
public const val MAX_VALUE: UShort = UShort(-1)
/**
* The number of bytes used to represent an instance of UShort in a binary form.
*/
public const val SIZE_BYTES: Int = 2
/**
* The number of bits used to represent an instance of UShort in a binary form.
*/
public const val SIZE_BITS: Int = 16
}
/**