struct Int
source · line 4public struct Int : Add<Int, Int>, Sub<Int, Int>, Mul<Int, Int>, Div<Int, Int>, Rem<Int, Int>, UnaryPlus<Int>, UnaryMinus<Int>, Increment<Int>, Decrement<Int>, Compare<Int>, RangeTo<Int, IntRange>, RangeUntil<Int, IntRange>, Equals<Int>, ToString, Hash
- Supertype
Add<Int, Int> - Supertype
Sub<Int, Int> - Supertype
Mul<Int, Int> - Supertype
Div<Int, Int> - Supertype
Rem<Int, Int> - Supertype
UnaryPlus<Int> - Supertype
UnaryMinus<Int> - Supertype
Increment<Int> - Supertype
Decrement<Int> - Supertype
Compare<Int> - Supertype
RangeTo<Int, IntRange> - Supertype
RangeUntil<Int, IntRange> - Supertype
Equals<Int> - Supertype
ToString - Supertype
Hash
A signed integer value with arithmetic and comparison operations.
Extensions
public fun Int.nanoseconds(): Duration· scoop:scoop.std:0.1.0public fun Int.microseconds(): Duration· scoop:scoop.std:0.1.0public fun Int.hours(): Duration· scoop:scoop.std:0.1.0public fun Int.milliseconds(): Duration· scoop:scoop.std:0.1.0public fun Int.minutes(): Duration· scoop:scoop.std:0.1.0public fun Int.toString(radix: Int): String· scoop:scoop.std:0.1.0public fun Int.toBigInteger(): BigInteger· scoop:scoop.math:0.1.0public fun Int.toBigDecimal(): BigDecimal· scoop:scoop.math:0.1.0public fun Int.days(): Duration· scoop:scoop.std:0.1.0public fun Int.toChar(): Char· scoop:scoop.core:0.1.0public fun Int.seconds(): Duration· scoop:scoop.std:0.1.0
function toByte
source · line 164@NoGC
@Intrinsic("int_to_int8")
public fun toByte(): Byte
Converts modulo 2^8 and interprets the result as a 8-bit signed integer. The conversion always succeeds.
function plus
source · line 72@NoGC
@Intrinsic("int_add")
public override operator fun plus(other: Int): Int
- Overrides
plus· Add
Returns the sum modulo 2^32; overflow does not throw.
parameter other
source · line 74other: Int
function toUInt
source · line 212@NoGC
@Intrinsic("int_to_uint")
public fun toUInt(): UInt
Converts modulo 2^32 and interprets the result as a 32-bit unsigned integer. The conversion always succeeds.
function toLong
source · line 188@NoGC
@Intrinsic("int_to_long")
public fun toLong(): Long
Converts modulo 2^64 and interprets the result as a 64-bit signed integer. The conversion always succeeds.
function toString
source · line 251public override fun toString(): String
- Overrides
toString· ToString
Returns the locale-independent decimal representation of this integer.
function shr
source · line 149@NoGC
@Intrinsic("int_shr")
public infix fun shr(count: Long): Int
Shifts right using the low 5 bits of the Long count, replicating the sign bit.
parameter count
source · line 151count: Long
function rem
source · line 101@Intrinsic("int_rem")
public override operator fun rem(other: Int): Int
- Overrides
rem· Rem
Returns the remainder associated with division truncated toward zero. A zero divisor throws ArithmeticException. A nonzero remainder has the dividend's sign.
parameter other
source · line 102other: Int
function rangeUntil
source · line 233public override operator fun rangeUntil(endpoint: Int): IntRange
- Overrides
rangeUntil· RangeUntil
Creates an ascending range including this value and excluding the endpoint.
parameter endpoint
source · line 233endpoint: Int
function toFloat
source · line 21@NoGC @Intrinsic("int_to_float")
public fun toFloat(): Float
Rounds the integer directly to IEEE binary32 using round-to-nearest, ties-to-even.
function toDouble
source · line 27@NoGC @Intrinsic("int_to_double")
public fun toDouble(): Double
Rounds the integer directly to IEEE binary64 using round-to-nearest, ties-to-even.
function unaryPlus
source · line 44@NoGC
@Intrinsic("int_unary_plus")
public override operator fun unaryPlus(): Int
- Overrides
unaryPlus· UnaryPlus
Returns the unchanged integer value.
function until
source · line 239public infix fun until(endpoint: Int): IntRange
Creates an ascending range with an exclusive endpoint.
parameter endpoint
source · line 239endpoint: Int
function xor
source · line 128@NoGC
@Intrinsic("int_xor")
public infix fun xor(other: Int): Int
Sets each result bit where the corresponding 32-bit operand bits differ.
parameter other
source · line 130other: Int
function minus
source · line 79@NoGC
@Intrinsic("int_sub")
public override operator fun minus(other: Int): Int
- Overrides
minus· Sub
Returns the difference modulo 2^32; overflow does not throw.
parameter other
source · line 81other: Int
function inv
source · line 135@NoGC
@Intrinsic("int_inv")
public fun inv(): Int
Flips all 32 bits of the representation.
function rangeTo
source · line 227public override operator fun rangeTo(endpoint: Int): IntRange
- Overrides
rangeTo· RangeTo
Creates an ascending range including both this value and the endpoint.
parameter endpoint
source · line 227endpoint: Int
function inc
source · line 58@NoGC
@Intrinsic("int_inc")
public override operator fun inc(): Int
- Overrides
inc· Increment
Returns the value plus one, wrapping modulo 2^32.
function and
source · line 114@NoGC
@Intrinsic("int_and")
public infix fun and(other: Int): Int
Returns the bitwise intersection of the 32-bit operands.
parameter other
source · line 116other: Int
function equals
source · line 36@NoGC
@Intrinsic("int_equals")
public override operator fun equals(other: Int): Boolean
- Overrides
equals· Equals
Compares the mathematical values of two integers of the same type.
parameter other
source · line 38other: Int
function shl
source · line 142@NoGC
@Intrinsic("int_shl")
public infix fun shl(count: Long): Int
Shifts left using the low 5 bits of the Long count; shifted-out bits are discarded.
parameter count
source · line 144count: Long
function div
source · line 94@Intrinsic("int_div")
public override operator fun div(other: Int): Int
- Overrides
div· Div
Returns the quotient truncated toward zero. A zero divisor throws ArithmeticException. The minimum value divided by -1 wraps to the minimum value.
parameter other
source · line 95other: Int
function unaryMinus
source · line 51@NoGC
@Intrinsic("int_unary_minus")
public override operator fun unaryMinus(): Int
- Overrides
unaryMinus· UnaryMinus
Returns the additive inverse modulo 2^32, including at the representation boundary.
function toInt
source · line 180@NoGC
@Intrinsic("int_to_int")
public fun toInt(): Int
Converts modulo 2^32 and interprets the result as a 32-bit signed integer. The conversion always succeeds.
function toUShort
source · line 204@NoGC
@Intrinsic("int_to_uint16")
public fun toUShort(): UShort
Converts modulo 2^16 and interprets the result as a 16-bit unsigned integer. The conversion always succeeds.
function toULong
source · line 220@NoGC
@Intrinsic("int_to_ulong")
public fun toULong(): ULong
Converts modulo 2^64 and interprets the result as a 64-bit unsigned integer. The conversion always succeeds.
function ushr
source · line 156@NoGC
@Intrinsic("int_ushr")
public infix fun ushr(count: Long): Int
Shifts right with zero fill using the low 5 bits of the Long count.
parameter count
source · line 158count: Long
function hash
source · line 256public override fun hash(): Long
- Overrides
hash· Hash
Returns a hash consistent with same-type integer equality.
function times
source · line 86@NoGC
@Intrinsic("int_mul")
public override operator fun times(other: Int): Int
- Overrides
times· Mul
Returns the product modulo 2^32; overflow does not throw.
parameter other
source · line 88other: Int
function or
source · line 121@NoGC
@Intrinsic("int_or")
public infix fun or(other: Int): Int
Returns the bitwise union of the 32-bit operands.
parameter other
source · line 123other: Int
function downTo
source · line 245public infix fun downTo(endpoint: Int): IntRange
Creates a descending range including both endpoints.
parameter endpoint
source · line 245endpoint: Int
function toUByte
source · line 196@NoGC
@Intrinsic("int_to_uint8")
public fun toUByte(): UByte
Converts modulo 2^8 and interprets the result as a 8-bit unsigned integer. The conversion always succeeds.
function dec
source · line 65@NoGC
@Intrinsic("int_dec")
public override operator fun dec(): Int
- Overrides
dec· Decrement
Returns the value minus one, wrapping modulo 2^32.
function compareTo
source · line 107@NoGC
@Intrinsic("int_compare_to")
public override operator fun compareTo(other: Int): Long
- Overrides
compareTo· Compare
Returns -1, 0, or 1 using signed mathematical ordering.
parameter other
source · line 109other: Int
function toShort
source · line 172@NoGC
@Intrinsic("int_to_int16")
public fun toShort(): Short
Converts modulo 2^16 and interprets the result as a 16-bit signed integer. The conversion always succeeds.