Short

Common
JVM
JS
Native
1.0
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

Common
JVM
JS
Native
1.0

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
Common
JVM
JS
Native
1.0

dec

Decrements this value.

operator fun dec(): Short
Common
JVM
JS
Native
1.0

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
Native
1.3

equals

fun equals(other: Short): Boolean

Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements:

fun equals(other: Any?): Boolean
Native
1.3

hashCode

Returns a hash code value for the object. The general contract of hashCode is:

fun hashCode(): Int
Common
JVM
JS
Native
1.0

inc

Increments this value.

operator fun inc(): Short
Common
JVM
JS
Native
1.0

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
Common
JVM
JS
Native
1.0

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
Common
JVM
JS
Native
1.0

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
Common
JVM
JS
Native
1.0

rangeTo

Creates a range from this value to the specified other value.

operator fun rangeTo(other: Byte): IntRange
operator fun rangeTo(other: Short): IntRange
operator fun rangeTo(other: Int): IntRange
operator fun rangeTo(other: Long): LongRange
Common
JVM
JS
Native
1.1

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
Common
JVM
JS
Native
1.0

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
Common
JVM
JS
Native
1.0

toByte

Returns the value of this number as a Byte, which may involve rounding or truncation.

fun toByte(): Byte
Common
JVM
JS
Native
1.0

toChar

Returns the Char with the numeric value equal to this number, truncated to 16 bits if appropriate.

fun toChar(): Char
Common
JVM
JS
Native
1.0

toDouble

Returns the value of this number as a Double, which may involve rounding.

fun toDouble(): Double
Common
JVM
JS
Native
1.0

toFloat

Returns the value of this number as a Float, which may involve rounding.

fun toFloat(): Float
Common
JVM
JS
Native
1.0

toInt

Returns the value of this number as an Int, which may involve rounding or truncation.

fun toInt(): Int
Common
JVM
JS
Native
1.0

toLong

Returns the value of this number as a Long, which may involve rounding or truncation.

fun toLong(): Long
Common
JVM
JS
Native
1.0

toShort

Returns the value of this number as a Short, which may involve rounding or truncation.

fun toShort(): Short
Native
1.3

toString

Returns a string representation of the object.

fun toString(): String
Common
JVM
JS
Native
1.0

unaryMinus

Returns the negative of this value.

operator fun unaryMinus(): Int
Common
JVM
JS
Native
1.0

unaryPlus

Returns this value.

operator fun unaryPlus(): Int

Companion Object Properties

Common
JVM
JS
Native
1.0

MAX_VALUE

A constant holding the maximum value an instance of Short can have.

const val MAX_VALUE: Short
Common
JVM
JS
Native
1.0

MIN_VALUE

A constant holding the minimum value an instance of Short can have.

const val MIN_VALUE: Short
Common
JVM
JS
Native
1.3

SIZE_BITS

The number of bits used to represent an instance of Short in a binary form.

const val SIZE_BITS: Int
Common
JVM
JS
Native
1.3

SIZE_BYTES

The number of bytes used to represent an instance of Short in a binary form.

const val SIZE_BYTES: Int

Extension Functions

Common
JVM
JS
Native
1.1

and

Performs a bitwise AND operation between the two values.

infix fun Short.and(other: Short): Short
Common
JVM
JS
Native
1.0

coerceAtLeast

Ensures that this value is not less than the specified minimumValue.

fun Short.coerceAtLeast(minimumValue: Short): Short
fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): T
Common
JVM
JS
Native
1.0

coerceAtMost

Ensures that this value is not greater than the specified maximumValue.

fun Short.coerceAtMost(maximumValue: Short): Short
fun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): T
Common
JVM
JS
Native
1.0

coerceIn

Ensures that this value lies in the specified range minimumValue..maximumValue.

fun Short.coerceIn(
    minimumValue: Short,
    maximumValue: Short
): Short
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
Native
1.3

convert

fun <R : Any> Short.convert(): R
Common
JVM
JS
Native
1.0

downTo

Returns a progression from this value down to the specified to value with the step -1.

infix fun Short.downTo(to: Byte): IntProgression
infix fun Short.downTo(to: Int): IntProgression
infix fun Short.downTo(to: Long): LongProgression
infix fun Short.downTo(to: Short): IntProgression
Common
JVM
JS
Native
1.1

inv

Inverts the bits in this value.

fun Short.inv(): Short
Native
1.3

narrow

fun <R : Number> Number.narrow(): R
Common
JVM
JS
Native
1.1

or

Performs a bitwise OR operation between the two values.

infix fun Short.or(other: Short): Short
Common
JVM
JS
Native
1.0

rangeTo

Creates a range from this Comparable value to the specified that value.

operator fun <T : Comparable<T>> T.rangeTo(
    that: T
): ClosedRange<T>
Native
1.3

signExtend

fun <R : Number> Number.signExtend(): R
Common
JVM
JS
Native
1.3

toUByte

fun Short.toUByte(): UByte
Common
JVM
JS
Native
1.3

toUInt

fun Short.toUInt(): UInt
Common
JVM
JS
Native
1.3

toULong

fun Short.toULong(): ULong
Common
JVM
JS
Native
1.3

toUShort

fun Short.toUShort(): UShort
Common
JVM
JS
Native
1.0

until

Returns a range from this value up to but excluding the specified to value.

infix fun Short.until(to: Byte): IntRange
infix fun Short.until(to: Int): IntRange
infix fun Short.until(to: Long): LongRange
infix fun Short.until(to: Short): IntRange
Common
JVM
JS
Native
1.1

xor

Performs a bitwise XOR operation between the two values.

infix fun Short.xor(other: Short): Short