compareTo

operator fun compareTo(other: Decimal): Int

Compares this decimal with the other one for order.

Returns a negative number, zero, or a positive number as this decimal is less than, equal to, or greater than the other one.


Calling from Kotlin

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

val x: Decimal = Decimal.parse("-99999999999999999999.99")
val y: Decimal = Decimal.parse("99999999999999999999.99")
val result: Boolean = x < y // or x.compareTo(y) < 0
check(result)

Calling from Java

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

final Decimal x = Decimal.parse("-99999999999999999999.99");
final Decimal y = Decimal.parse("99999999999999999999.99");
final boolean result = x.compareTo(y) < 0;
if (!result) throw new IllegalStateException("Check failed.");