div
Returns the quotient of dividing this integer by the other one, or throws an ArithmeticException if the other integer is zero.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
// Given
val x: Integer = Integer.fromDecimal("922337203685477580700")
val y: Integer = Integer.from(10)
// When
val result: Integer = x / y
// Then
val expected: Integer = Integer.fromDecimal("92233720368547758070")
check(result == expected)Content copied to clipboard
Calling from Java
Here's an example of calling this function from Java code:
// Given
final Integer x = Integer.fromDecimal("922337203685477580700");
final Integer y = Integer.from(10);
// When
final Integer result = x.div(y);
// Then
final Integer expected = Integer.fromDecimal("92233720368547758070");
final boolean check = result.equals(expected);
if (!check) throw new IllegalStateException("Check failed.");Content copied to clipboard
See the divOrNull function for returning null instead of throwing an exception in case of invalid other integer.