Byte
class Byte : Number, Comparable<Byte>
For Common, JVM, JS
Represents a 8-bit signed integer.
On the JVM, non-nullable values of this type are represented as values of the primitive type byte
.
For Native
Represents a 8-bit signed integer.
Functions
compareTo
Compares this value with the specified value for order. Returns zero if this value is equal to the specified other value, a negative number if it's less than other, or a positive number if it's greater than other.
operator fun compareTo(other: Byte): Int
operator fun compareTo(other: Short): Int
operator fun compareTo(other: Int): Int
operator fun compareTo(other: Long): Int
operator fun compareTo(other: Float): Int
operator fun compareTo(other: Double): Int
dec
Decrements this value.
operator fun dec(): Byte
div
Divides this value by the other value.
operator fun div(other: Byte): Int
operator fun div(other: Short): Int
operator fun div(other: Int): Int
operator fun div(other: Long): Long
operator fun div(other: Float): Float
operator fun div(other: Double): Double
equals
fun equals(other: Byte): Boolean
Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements:
fun equals(other: Any?): Boolean
hashCode
Returns a hash code value for the object. The general contract of hashCode
is:
fun hashCode(): Int
inc
Increments this value.
operator fun inc(): Byte
minus
Subtracts the other value from this value.
operator fun minus(other: Byte): Int
operator fun minus(other: Short): Int
operator fun minus(other: Int): Int
operator fun minus(other: Long): Long
operator fun minus(other: Float): Float
operator fun minus(other: Double): Double
mod
Calculates the remainder of dividing this value by the other value.
operator fun mod(other: Byte): Int
operator fun mod(other: Short): Int
operator fun mod(other: Int): Int
operator fun mod(other: Long): Long
operator fun mod(other: Float): Float
operator fun mod(other: Double): Double
plus
Adds the other value to this value.
operator fun plus(other: Byte): Int
operator fun plus(other: Short): Int
operator fun plus(other: Int): Int
operator fun plus(other: Long): Long
operator fun plus(other: Float): Float
operator fun plus(other: Double): Double
rem
Calculates the remainder of dividing this value by the other value.
operator fun rem(other: Byte): Int
operator fun rem(other: Short): Int
operator fun rem(other: Int): Int
operator fun rem(other: Long): Long
operator fun rem(other: Float): Float
operator fun rem(other: Double): Double
times
Multiplies this value by the other value.
operator fun times(other: Byte): Int
operator fun times(other: Short): Int
operator fun times(other: Int): Int
operator fun times(other: Long): Long
operator fun times(other: Float): Float
operator fun times(other: Double): Double
toByte
Returns this value.
fun toByte(): Byte
toString
Returns a string representation of the object.
fun toString(): String
unaryMinus
Returns the negative of this value.
operator fun unaryMinus(): Int
unaryPlus
Returns this value.
operator fun unaryPlus(): Int
Companion Object Properties
MAX_VALUE
A constant holding the maximum value an instance of Byte can have.
const val MAX_VALUE: Byte
MIN_VALUE
A constant holding the minimum value an instance of Byte can have.
const val MIN_VALUE: Byte
SIZE_BITS
The number of bits used to represent an instance of Byte in a binary form.
const val SIZE_BITS: Int
SIZE_BYTES
The number of bytes used to represent an instance of Byte in a binary form.
const val SIZE_BYTES: Int
Extension Functions
and
Performs a bitwise AND operation between the two values.
infix fun Byte.and(other: Byte): Byte
coerceAtLeast
Ensures that this value is not less than the specified minimumValue.
fun Byte.coerceAtLeast(minimumValue: Byte): Byte
fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): T
coerceAtMost
Ensures that this value is not greater than the specified maximumValue.
fun Byte.coerceAtMost(maximumValue: Byte): Byte
fun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): T
coerceIn
Ensures that this value lies in the specified range minimumValue..maximumValue.
fun Byte.coerceIn(
minimumValue: Byte,
maximumValue: Byte
): Byte
fun <T : Comparable<T>> T.coerceIn(
minimumValue: T?,
maximumValue: T?
): T
Ensures that this value lies in the specified range.
fun <T : Comparable<T>> T.coerceIn(
range: ClosedFloatingPointRange<T>
): T
fun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): T
convert
fun <R : Any> Byte.convert(): R
countLeadingZeroBits
Counts the number of consecutive most significant bits that are zero in the binary representation of this Byte number.
fun Byte.countLeadingZeroBits(): Int
countOneBits
Counts the number of set bits in the binary representation of this Byte number.
fun Byte.countOneBits(): Int
countTrailingZeroBits
Counts the number of consecutive least significant bits that are zero in the binary representation of this Byte number.
fun Byte.countTrailingZeroBits(): Int
downTo
Returns a progression from this value down to the specified to value with the step -1.
infix fun Byte.downTo(to: Byte): IntProgression
infix fun Byte.downTo(to: Int): IntProgression
infix fun Byte.downTo(to: Long): LongProgression
infix fun Byte.downTo(to: Short): IntProgression
inv
Inverts the bits in this value.
fun Byte.inv(): Byte
or
Performs a bitwise OR operation between the two values.
infix fun Byte.or(other: Byte): Byte
rangeTo
Creates a range from this Comparable value to the specified that value.
operator fun <T : Comparable<T>> T.rangeTo(
that: T
): ClosedRange<T>
takeHighestOneBit
Returns a number having a single bit set in the position of the most significant set bit of this Byte number, or zero, if this number is zero.
fun Byte.takeHighestOneBit(): Byte
takeLowestOneBit
Returns a number having a single bit set in the position of the least significant set bit of this Byte number, or zero, if this number is zero.
fun Byte.takeLowestOneBit(): Byte
toBoolean
fun Byte.toBoolean(): Boolean
xor
Performs a bitwise XOR operation between the two values.
infix fun Byte.xor(other: Byte): Byte