floor
Rounds the given value x to an integer towards negative infinity.
Special cases:
floor(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.2Return
the largest double value that is smaller than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.14159)) // 3.0
println(floor(-1.1)) // -2.0
// 10.0 is already an "integer", so no rounding will take place
println(floor(10.0)) // 10.0
// Special cases
println(floor(Double.NaN)) // NaN
println(floor(Double.POSITIVE_INFINITY)) // Infinity
println(floor(Double.NEGATIVE_INFINITY)) // -Infinity
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.5)) // 3.0
println(ceil(3.5)) // 4.0
println(truncate(3.5)) // 3.0
println(round(3.5)) // 4.0
println(round(3.49)) // 3.0
println(floor(-3.5)) // -4.0
println(ceil(-3.5)) // -3.0
println(truncate(-3.5)) // -3.0
println(round(-3.5)) // -4.0
println(round(-3.49)) // -3.0
//sampleEnd
}
Rounds the given value x to an integer towards negative infinity.
Special cases:
floor(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.2Return
the largest Float value that is smaller than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.14159f)) // 3.0
println(floor(-1.1f)) // -2.0
// 10.0 is already an "integer", so no rounding will take place
println(floor(10.0f)) // 10.0
// Special cases
println(floor(Float.NaN)) // NaN
println(floor(Float.POSITIVE_INFINITY)) // Infinity
println(floor(Float.NEGATIVE_INFINITY)) // -Infinity
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.5f)) // 3.0
println(ceil(3.5f)) // 4.0
println(truncate(3.5f)) // 3.0
println(round(3.5f)) // 4.0
println(round(3.49f)) // 3.0
println(floor(-3.5f)) // -4.0
println(ceil(-3.5f)) // -3.0
println(truncate(-3.5f)) // -3.0
println(round(-3.5f)) // -4.0
println(round(-3.49f)) // -3.0
//sampleEnd
}
Rounds the given value x to an integer towards negative infinity.
Special cases:
floor(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.2Return
the largest double value that is smaller than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.14159)) // 3.0
println(floor(-1.1)) // -2.0
// 10.0 is already an "integer", so no rounding will take place
println(floor(10.0)) // 10.0
// Special cases
println(floor(Double.NaN)) // NaN
println(floor(Double.POSITIVE_INFINITY)) // Infinity
println(floor(Double.NEGATIVE_INFINITY)) // -Infinity
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.5)) // 3.0
println(ceil(3.5)) // 4.0
println(truncate(3.5)) // 3.0
println(round(3.5)) // 4.0
println(round(3.49)) // 3.0
println(floor(-3.5)) // -4.0
println(ceil(-3.5)) // -3.0
println(truncate(-3.5)) // -3.0
println(round(-3.5)) // -4.0
println(round(-3.49)) // -3.0
//sampleEnd
}
Rounds the given value x to an integer towards negative infinity.
Special cases:
floor(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.2Return
the largest Float value that is smaller than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.14159f)) // 3.0
println(floor(-1.1f)) // -2.0
// 10.0 is already an "integer", so no rounding will take place
println(floor(10.0f)) // 10.0
// Special cases
println(floor(Float.NaN)) // NaN
println(floor(Float.POSITIVE_INFINITY)) // Infinity
println(floor(Float.NEGATIVE_INFINITY)) // -Infinity
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.5f)) // 3.0
println(ceil(3.5f)) // 4.0
println(truncate(3.5f)) // 3.0
println(round(3.5f)) // 4.0
println(round(3.49f)) // 3.0
println(floor(-3.5f)) // -4.0
println(ceil(-3.5f)) // -3.0
println(truncate(-3.5f)) // -3.0
println(round(-3.5f)) // -4.0
println(round(-3.49f)) // -3.0
//sampleEnd
}
Rounds the given value x to an integer towards negative infinity.
Special cases:
floor(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.2Return
the largest double value that is smaller than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.14159)) // 3.0
println(floor(-1.1)) // -2.0
// 10.0 is already an "integer", so no rounding will take place
println(floor(10.0)) // 10.0
// Special cases
println(floor(Double.NaN)) // NaN
println(floor(Double.POSITIVE_INFINITY)) // Infinity
println(floor(Double.NEGATIVE_INFINITY)) // -Infinity
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.5)) // 3.0
println(ceil(3.5)) // 4.0
println(truncate(3.5)) // 3.0
println(round(3.5)) // 4.0
println(round(3.49)) // 3.0
println(floor(-3.5)) // -4.0
println(ceil(-3.5)) // -3.0
println(truncate(-3.5)) // -3.0
println(round(-3.5)) // -4.0
println(round(-3.49)) // -3.0
//sampleEnd
}
Rounds the given value x to an integer towards negative infinity.
Special cases:
floor(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.2Return
the largest Float value that is smaller than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.14159f)) // 3.0
println(floor(-1.1f)) // -2.0
// 10.0 is already an "integer", so no rounding will take place
println(floor(10.0f)) // 10.0
// Special cases
println(floor(Float.NaN)) // NaN
println(floor(Float.POSITIVE_INFINITY)) // Infinity
println(floor(Float.NEGATIVE_INFINITY)) // -Infinity
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.5f)) // 3.0
println(ceil(3.5f)) // 4.0
println(truncate(3.5f)) // 3.0
println(round(3.5f)) // 4.0
println(round(3.49f)) // 3.0
println(floor(-3.5f)) // -4.0
println(ceil(-3.5f)) // -3.0
println(truncate(-3.5f)) // -3.0
println(round(-3.5f)) // -4.0
println(round(-3.49f)) // -3.0
//sampleEnd
}
Rounds the given value x to an integer towards negative infinity.
Special cases:
floor(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.3Return
the largest double value that is smaller than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.14159)) // 3.0
println(floor(-1.1)) // -2.0
// 10.0 is already an "integer", so no rounding will take place
println(floor(10.0)) // 10.0
// Special cases
println(floor(Double.NaN)) // NaN
println(floor(Double.POSITIVE_INFINITY)) // Infinity
println(floor(Double.NEGATIVE_INFINITY)) // -Infinity
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.5)) // 3.0
println(ceil(3.5)) // 4.0
println(truncate(3.5)) // 3.0
println(round(3.5)) // 4.0
println(round(3.49)) // 3.0
println(floor(-3.5)) // -4.0
println(ceil(-3.5)) // -3.0
println(truncate(-3.5)) // -3.0
println(round(-3.5)) // -4.0
println(round(-3.49)) // -3.0
//sampleEnd
}
Rounds the given value x to an integer towards negative infinity.
Special cases:
floor(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.3Return
the largest Float value that is smaller than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.14159f)) // 3.0
println(floor(-1.1f)) // -2.0
// 10.0 is already an "integer", so no rounding will take place
println(floor(10.0f)) // 10.0
// Special cases
println(floor(Float.NaN)) // NaN
println(floor(Float.POSITIVE_INFINITY)) // Infinity
println(floor(Float.NEGATIVE_INFINITY)) // -Infinity
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.5f)) // 3.0
println(ceil(3.5f)) // 4.0
println(truncate(3.5f)) // 3.0
println(round(3.5f)) // 4.0
println(round(3.49f)) // 3.0
println(floor(-3.5f)) // -4.0
println(ceil(-3.5f)) // -3.0
println(truncate(-3.5f)) // -3.0
println(round(-3.5f)) // -4.0
println(round(-3.49f)) // -3.0
//sampleEnd
}
Rounds the given value x to an integer towards negative infinity.
Special cases:
floor(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.8Return
the largest double value that is smaller than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.14159)) // 3.0
println(floor(-1.1)) // -2.0
// 10.0 is already an "integer", so no rounding will take place
println(floor(10.0)) // 10.0
// Special cases
println(floor(Double.NaN)) // NaN
println(floor(Double.POSITIVE_INFINITY)) // Infinity
println(floor(Double.NEGATIVE_INFINITY)) // -Infinity
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.5)) // 3.0
println(ceil(3.5)) // 4.0
println(truncate(3.5)) // 3.0
println(round(3.5)) // 4.0
println(round(3.49)) // 3.0
println(floor(-3.5)) // -4.0
println(ceil(-3.5)) // -3.0
println(truncate(-3.5)) // -3.0
println(round(-3.5)) // -4.0
println(round(-3.49)) // -3.0
//sampleEnd
}
Rounds the given value x to an integer towards negative infinity.
Special cases:
floor(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.8Return
the largest Float value that is smaller than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.14159f)) // 3.0
println(floor(-1.1f)) // -2.0
// 10.0 is already an "integer", so no rounding will take place
println(floor(10.0f)) // 10.0
// Special cases
println(floor(Float.NaN)) // NaN
println(floor(Float.POSITIVE_INFINITY)) // Infinity
println(floor(Float.NEGATIVE_INFINITY)) // -Infinity
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.5f)) // 3.0
println(ceil(3.5f)) // 4.0
println(truncate(3.5f)) // 3.0
println(round(3.5f)) // 4.0
println(round(3.49f)) // 3.0
println(floor(-3.5f)) // -4.0
println(ceil(-3.5f)) // -3.0
println(truncate(-3.5f)) // -3.0
println(round(-3.5f)) // -4.0
println(round(-3.49f)) // -3.0
//sampleEnd
}
Rounds the given value x to an integer towards negative infinity.
Special cases:
floor(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.8Return
the largest double value that is smaller than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.14159)) // 3.0
println(floor(-1.1)) // -2.0
// 10.0 is already an "integer", so no rounding will take place
println(floor(10.0)) // 10.0
// Special cases
println(floor(Double.NaN)) // NaN
println(floor(Double.POSITIVE_INFINITY)) // Infinity
println(floor(Double.NEGATIVE_INFINITY)) // -Infinity
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.5)) // 3.0
println(ceil(3.5)) // 4.0
println(truncate(3.5)) // 3.0
println(round(3.5)) // 4.0
println(round(3.49)) // 3.0
println(floor(-3.5)) // -4.0
println(ceil(-3.5)) // -3.0
println(truncate(-3.5)) // -3.0
println(round(-3.5)) // -4.0
println(round(-3.49)) // -3.0
//sampleEnd
}
Rounds the given value x to an integer towards negative infinity.
Special cases:
floor(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.8Return
the largest Float value that is smaller than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.14159f)) // 3.0
println(floor(-1.1f)) // -2.0
// 10.0 is already an "integer", so no rounding will take place
println(floor(10.0f)) // 10.0
// Special cases
println(floor(Float.NaN)) // NaN
println(floor(Float.POSITIVE_INFINITY)) // Infinity
println(floor(Float.NEGATIVE_INFINITY)) // -Infinity
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(floor(3.5f)) // 3.0
println(ceil(3.5f)) // 4.0
println(truncate(3.5f)) // 3.0
println(round(3.5f)) // 4.0
println(round(3.49f)) // 3.0
println(floor(-3.5f)) // -4.0
println(ceil(-3.5f)) // -3.0
println(truncate(-3.5f)) // -3.0
println(round(-3.5f)) // -4.0
println(round(-3.49f)) // -3.0
//sampleEnd
}