mod
Calculates the remainder of flooring division of this value (dividend) by the other value (divisor).
The result is always less than the divisor.
For unsigned types, the remainders of flooring division and truncating division are the same.
Since Kotlin
1.5Samples
import kotlin.test.assertFailsWith
fun main() {
//sampleStart
// Unsigned types have no negative values, so mod produces the
// same result as the % operator
println(7u.mod(3u)) // 1
println(7u % 3u) // 1
// A zero divisor throws
// 1u.mod(0u) // will fail with ArithmeticException
//sampleEnd
}Content copied to clipboard