Int
class Int : Number, Comparable<Int>For Common, JVM, JS
Represents a 32-bit signed integer.
On the JVM, non-nullable values of this type are represented as values of the primitive type int.
For Native
Represents a 32-bit signed integer.
Functions
and
Performs a bitwise AND operation between the two values.
infix fun and(other: Int): IntcompareTo
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(): Intdiv
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: Int): 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(): Intinv
Inverts the bits in this value.
fun inv(): Intminus
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): Doubleor
Performs a bitwise OR operation between the two values.
infix fun or(other: Int): Intplus
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): Doubleshr
Shifts this value right by the bitCount number of bits, filling the leftmost bits with copies of the sign bit.
infix fun shr(bitCount: Int): Inttimes
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): DoubletoInt
Returns this value.
fun toInt(): InttoString
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(): Intushr
Shifts this value right by the bitCount number of bits, filling the leftmost bits with zeros.
infix fun ushr(bitCount: Int): Intxor
Performs a bitwise XOR operation between the two values.
infix fun xor(other: Int): IntCompanion Object Properties
MAX_VALUE
A constant holding the maximum value an instance of Int can have.
const val MAX_VALUE: IntMIN_VALUE
A constant holding the minimum value an instance of Int can have.
const val MIN_VALUE: IntSIZE_BITS
The number of bits used to represent an instance of Int in a binary form.
const val SIZE_BITS: IntSIZE_BYTES
The number of bytes used to represent an instance of Int in a binary form.
const val SIZE_BYTES: IntExtension Properties
Extension Functions
coerceAtLeast
Ensures that this value is not less than the specified minimumValue.
fun Int.coerceAtLeast(minimumValue: Int): Intfun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): TcoerceAtMost
Ensures that this value is not greater than the specified maximumValue.
fun Int.coerceAtMost(maximumValue: Int): Intfun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): TcoerceIn
Ensures that this value lies in the specified range minimumValue..maximumValue.
fun Int.coerceIn(minimumValue: Int, maximumValue: Int): Intfun <T : Comparable<T>> T.coerceIn(
minimumValue: T?,
maximumValue: T?
): TEnsures that this value lies in the specified range.
fun Int.coerceIn(range: ClosedRange<Int>): Intfun <T : Comparable<T>> T.coerceIn(
range: ClosedFloatingPointRange<T>
): Tfun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): Tconvert
fun <R : Any> Int.convert(): RdownTo
Returns a progression from this value down to the specified to value with the step -1.
infix fun Int.downTo(to: Byte): IntProgressioninfix fun Int.downTo(to: Int): IntProgressioninfix fun Int.downTo(to: Long): LongProgressioninfix fun Int.downTo(to: Short): IntProgressionrangeTo
Creates a range from this Comparable value to the specified that value.
operator fun <T : Comparable<T>> T.rangeTo(
that: T
): ClosedRange<T>toBigDecimal
Returns the value of this Int number as a BigDecimal.
fun Int.toBigDecimal(): BigDecimalfun Int.toBigDecimal(mathContext: MathContext): BigDecimaltoBigInteger
Returns the value of this Int number as a BigInteger.
fun Int.toBigInteger(): BigIntegertoDuration
Returns a Duration equal to this Int number of the specified unit.
fun Int.toDuration(unit: DurationUnit): Duration