Package-level declarations

Contains types such as NonZeroInt for manipulating numbers.

Types

Link copied to clipboard
@Serializable(with = AnyIntSerializer::class)
@Since(version = KotoolsTypesVersion.V4_0_0)
interface AnyInt : Comparable<AnyInt>

Represents an integer number of type Int.

Link copied to clipboard
@Serializable(with = NegativeIntSerializer::class)
@Since(version = KotoolsTypesVersion.V1_1_0)
interface NegativeInt : AnyInt

Represents an integer number of type Int that is less than or equals zero.

Link copied to clipboard
@Serializable(with = NonZeroIntSerializer::class)
@Since(version = KotoolsTypesVersion.V1_1_0)
interface NonZeroInt : AnyInt

Represents an integer number of type Int that is other than zero.

Link copied to clipboard
@Serializable(with = PositiveIntSerializer::class)
@Since(version = KotoolsTypesVersion.V1_1_0)
interface PositiveInt : AnyInt

Represents an integer number of type Int that is greater than or equals zero.

Link copied to clipboard
@Serializable(with = StrictlyNegativeIntSerializer::class)
@Since(version = KotoolsTypesVersion.V1_1_0)
value class StrictlyNegativeInt : NonZeroInt, NegativeInt

Represents an integer number of type Int that is less than zero.

Link copied to clipboard
@Serializable(with = StrictlyPositiveIntSerializer::class)
@Since(version = KotoolsTypesVersion.V1_1_0)
value class StrictlyPositiveInt : NonZeroInt, PositiveInt

Represents an integer number of type Int that is greater than zero.

Link copied to clipboard
@Serializable(with = ZeroIntSerializer::class)
@Since(version = KotoolsTypesVersion.V4_0_0)
object ZeroInt : PositiveInt, NegativeInt

Represents an integer number of type Int that equals zero.

Functions

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun Int.div(other: NonZeroInt): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.div(other: NonZeroInt): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun NegativeInt.div(other: StrictlyNegativeInt): PositiveInt
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun NegativeInt.div(other: StrictlyPositiveInt): NegativeInt
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun PositiveInt.div(other: StrictlyNegativeInt): NegativeInt
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun PositiveInt.div(other: StrictlyPositiveInt): PositiveInt

Divides this integer by the other one, truncating the result to an integer that is closer to zero.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun Int.minus(other: AnyInt): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.minus(other: Int): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.minus(other: AnyInt): Int

Subtracts the other integer from this one.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun Int.plus(other: AnyInt): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.plus(other: Int): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.plus(other: AnyInt): Int

Adds the other integer to this one.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun Int.rem(other: NonZeroInt): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.rem(other: NonZeroInt): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun NegativeInt.rem(other: NonZeroInt): NegativeInt
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun PositiveInt.rem(other: NonZeroInt): PositiveInt

Calculates the remainder of truncating division of this integer by the other one.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun Int.times(other: AnyInt): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.times(other: Int): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.times(other: AnyInt): Int

Multiplies this integer by the other one.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
fun Number.toNegativeInt(): Result<NegativeInt>

Returns this number as an encapsulated NegativeInt, which may involve rounding or truncation, or returns an encapsulated IllegalArgumentException if this number is strictly positive.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
fun Number.toNonZeroInt(): Result<NonZeroInt>

Returns this number as an encapsulated NonZeroInt, which may involve rounding or truncation, or returns an encapsulated IllegalArgumentException if this number equals zero.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
fun Number.toPositiveInt(): Result<PositiveInt>

Returns this number as an encapsulated PositiveInt, which may involve rounding or truncation, or returns an encapsulated IllegalArgumentException if this number is strictly negative.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
fun Number.toStrictlyNegativeInt(): Result<StrictlyNegativeInt>

Returns this number as an encapsulated StrictlyNegativeInt, which may involve rounding or truncation, or returns an encapsulated IllegalArgumentException if this number is positive.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
fun Number.toStrictlyPositiveInt(): Result<StrictlyPositiveInt>

Returns this number as an encapsulated StrictlyPositiveInt, which may involve rounding or truncation, or returns an encapsulated IllegalArgumentException if this number is negative.