floor Div
Начиная с Kotlin: 1.5
inline fun floorDiv(other: UByte): UInt
inline fun floorDiv(other: UShort): UInt
inline fun floorDiv(other: UInt): UInt
inline fun floorDiv(other: ULong): ULong
Делит это значение на другое, округляя результат до целого числа в сторону минус бесконечности.
Для беззнаковых типов результаты деления с округлением вниз и деления с усечением совпадают.
Примеры
import kotlin.test.assertFailsWith
fun main() {
//sampleStart
// Unsigned types have no negative values, so floorDiv produces the
// same result as the / operator
println(7u.floorDiv(3u)) // 2
println(7u / 3u) // 2
// Dividing by zero throws
// 1u.floorDiv(0u) // will fail with ArithmeticException
//sampleEnd
}
© 2010–2026 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-u-short/floor-div.html