unaryMinus

@ExperimentalSince(version = KotoolsTypesVersion.V4_4_0)
operator fun AnyInt.unaryMinus(): AnyInt

Returns the negative of this integer number.


Calling from Kotlin

Here's an example of calling this function from Kotlin code:

val number = AnyInt(1)
val result: AnyInt = -number // or number.unaryMinus()
assertEquals(expected = "-1", actual = "$result")

Please note that this function is not available yet for Java users.


@ExperimentalSince(version = KotoolsTypesVersion.V4_4_0)
operator fun NegativeInt.unaryMinus(): PositiveInt

Returns the negative of this integer number.


Calling from Kotlin

Here's an example of calling this function from Kotlin code:

val number: NegativeInt = (-1).toNegativeInt()
.getOrThrow()
val result: PositiveInt = -number // or number.unaryMinus()
assertEquals(expected = "1", actual = "$result")

Please note that this function is not available yet for Java users.


@ExperimentalSince(version = KotoolsTypesVersion.V4_4_0)
operator fun NonZeroInt.unaryMinus(): NonZeroInt

Returns the negative of this integer number.


Calling from Kotlin

Here's an example of calling this function from Kotlin code:

val number: NonZeroInt = 1.toNonZeroInt()
.getOrThrow()
val result: NonZeroInt = -number // or number.unaryMinus()
assertEquals(expected = "-1", actual = "$result")

Please note that this function is not available yet for Java users.


@ExperimentalSince(version = KotoolsTypesVersion.V4_4_0)
operator fun PositiveInt.unaryMinus(): NegativeInt

Returns the negative of this integer number.


Calling from Kotlin

Here's an example of calling this function from Kotlin code:

val number: PositiveInt = 1.toPositiveInt()
.getOrThrow()
val result: NegativeInt = -number // or number.unaryMinus()
assertEquals(expected = "-1", actual = "$result")

Please note that this function is not available yet for Java users.


@ExperimentalSince(version = KotoolsTypesVersion.V4_4_0)
operator fun StrictlyNegativeInt.unaryMinus(): StrictlyPositiveInt

Returns the negative of this integer number.


Calling from Kotlin

Here's an example of calling this function from Kotlin code:

val number: StrictlyNegativeInt = (-1).toStrictlyNegativeInt()
.getOrThrow()
val result: StrictlyPositiveInt = -number // or number.unaryMinus()
assertEquals(expected = "1", actual = "$result")

Please note that this function is not available yet for Java users.


@ExperimentalSince(version = KotoolsTypesVersion.V4_4_0)
operator fun StrictlyPositiveInt.unaryMinus(): StrictlyNegativeInt

Returns the negative of this integer number.


Calling from Kotlin

Here's an example of calling this function from Kotlin code:

val number: StrictlyPositiveInt = 1.toStrictlyPositiveInt()
.getOrThrow()
val result: StrictlyNegativeInt = -number // or number.unaryMinus()
assertEquals(expected = "-1", actual = "$result")

Please note that this function is not available yet for Java users.