floorDiv

inline fun Byte.floorDiv(other: Byte): Int(source)
inline fun Byte.floorDiv(other: Short): Int(source)
inline fun Byte.floorDiv(other: Int): Int(source)
inline fun Byte.floorDiv(other: Long): Long(source)
inline fun Short.floorDiv(other: Byte): Int(source)
inline fun Short.floorDiv(other: Short): Int(source)
inline fun Short.floorDiv(other: Int): Int(source)
inline fun Short.floorDiv(other: Long): Long(source)
inline fun Int.floorDiv(other: Byte): Int(source)
inline fun Int.floorDiv(other: Short): Int(source)
inline fun Int.floorDiv(other: Int): Int(source)
inline fun Int.floorDiv(other: Long): Long(source)
inline fun Long.floorDiv(other: Byte): Long(source)
inline fun Long.floorDiv(other: Short): Long(source)
inline fun Long.floorDiv(other: Int): Long(source)
inline fun Long.floorDiv(other: Long): Long(source)

Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.

Since Kotlin

1.5

Samples

import kotlin.test.assertFailsWith

fun main() { 
   //sampleStart 
   // Regular integer division (/) truncates toward zero
println((-7) / 3) // -2
// floorDiv rounds toward negative infinity
println((-7).floorDiv(3)) // -3
println(7.floorDiv(3)) // 2
println(7.floorDiv(-3)) // -3

// Dividing by zero throws, just like the / operator
// 1.floorDiv(0) // will fail with ArithmeticException 
   //sampleEnd
}