Short
class Short : Number, Comparable<Short>For Common, JVM, JS
Represents a 16-bit signed integer.
On the JVM, non-nullable values of this type are represented as values of the primitive type short.
For Native
Represents a 16-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): Intoperator fun compareTo(other: Short): Intoperator fun compareTo(other: Int): Intoperator fun compareTo(other: Long): Intoperator fun compareTo(other: Float): Intoperator fun compareTo(other: Double): Intdec
Decrements this value.
operator fun dec(): Shortdiv
Divides this value by the other value.
operator fun div(other: Byte): Intoperator fun div(other: Short): Intoperator fun div(other: Int): Intoperator fun div(other: Long): Longoperator fun div(other: Float): Floatoperator fun div(other: Double): Doubleequals
fun equals(other: Short): BooleanIndicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements:
fun equals(other: Any?): BooleanhashCode
Returns a hash code value for the object. The general contract of hashCode is:
fun hashCode(): Intinc
Increments this value.
operator fun inc(): Shortminus
Subtracts the other value from this value.
operator fun minus(other: Byte): Intoperator fun minus(other: Short): Intoperator fun minus(other: Int): Intoperator fun minus(other: Long): Longoperator fun minus(other: Float): Floatoperator fun minus(other: Double): Doublemod
Calculates the remainder of dividing this value by the other value.
operator fun mod(other: Byte): Intoperator fun mod(other: Short): Intoperator fun mod(other: Int): Intoperator fun mod(other: Long): Longoperator fun mod(other: Float): Floatoperator fun mod(other: Double): Doubleplus
Adds the other value to this value.
operator fun plus(other: Byte): Intoperator fun plus(other: Short): Intoperator fun plus(other: Int): Intoperator fun plus(other: Long): Longoperator fun plus(other: Float): Floatoperator fun plus(other: Double): Doublerem
Calculates the remainder of dividing this value by the other value.
operator fun rem(other: Byte): Intoperator fun rem(other: Short): Intoperator fun rem(other: Int): Intoperator fun rem(other: Long): Longoperator fun rem(other: Float): Floatoperator fun rem(other: Double): Doubletimes
Multiplies this value by the other value.
operator fun times(other: Byte): Intoperator fun times(other: Short): Intoperator fun times(other: Int): Intoperator fun times(other: Long): Longoperator fun times(other: Float): Floatoperator fun times(other: Double): DoubletoShort
Returns this value.
fun toShort(): ShorttoString
Returns a string representation of the object.
fun toString(): StringunaryMinus
Returns the negative of this value.
operator fun unaryMinus(): IntunaryPlus
Returns this value.
operator fun unaryPlus(): IntCompanion Object Properties
MAX_VALUE
A constant holding the maximum value an instance of Short can have.
const val MAX_VALUE: ShortMIN_VALUE
A constant holding the minimum value an instance of Short can have.
const val MIN_VALUE: ShortSIZE_BITS
The number of bits used to represent an instance of Short in a binary form.
const val SIZE_BITS: IntSIZE_BYTES
The number of bytes used to represent an instance of Short in a binary form.
const val SIZE_BYTES: IntExtension Functions
and
Performs a bitwise AND operation between the two values.
infix fun Short.and(other: Short): ShortcoerceAtLeast
Ensures that this value is not less than the specified minimumValue.
fun Short.coerceAtLeast(minimumValue: Short): Shortfun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): TcoerceAtMost
Ensures that this value is not greater than the specified maximumValue.
fun Short.coerceAtMost(maximumValue: Short): Shortfun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): TcoerceIn
Ensures that this value lies in the specified range minimumValue..maximumValue.
fun Short.coerceIn(
minimumValue: Short,
maximumValue: Short
): Shortfun <T : Comparable<T>> T.coerceIn(
minimumValue: T?,
maximumValue: T?
): TEnsures that this value lies in the specified range.
fun <T : Comparable<T>> T.coerceIn(
range: ClosedFloatingPointRange<T>
): Tfun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): Tconvert
fun <R : Any> Short.convert(): RcountLeadingZeroBits
Counts the number of consecutive most significant bits that are zero in the binary representation of this Short number.
fun Short.countLeadingZeroBits(): IntcountOneBits
Counts the number of set bits in the binary representation of this Short number.
fun Short.countOneBits(): IntcountTrailingZeroBits
Counts the number of consecutive least significant bits that are zero in the binary representation of this Short number.
fun Short.countTrailingZeroBits(): IntdownTo
Returns a progression from this value down to the specified to value with the step -1.
infix fun Short.downTo(to: Byte): IntProgressioninfix fun Short.downTo(to: Int): IntProgressioninfix fun Short.downTo(to: Long): LongProgressioninfix fun Short.downTo(to: Short): IntProgressioninv
Inverts the bits in this value.
fun Short.inv(): Shortor
Performs a bitwise OR operation between the two values.
infix fun Short.or(other: Short): ShortrangeTo
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 Short number, or zero, if this number is zero.
fun Short.takeHighestOneBit(): ShorttakeLowestOneBit
Returns a number having a single bit set in the position of the least significant set bit of this Short number, or zero, if this number is zero.
fun Short.takeLowestOneBit(): Shortxor
Performs a bitwise XOR operation between the two values.
infix fun Short.xor(other: Short): Short