ceil
Rounds the given value x to an integer towards positive infinity.
Special cases:
ceil(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.2Return
the smallest double value that is greater than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(ceil(3.14159)) // 4.0
println(ceil(-1.1)) // -1.0
// 10.0 is already an "integer", so no rounding will take place
println(ceil(10.0)) // 10.0
// Special cases
println(ceil(Double.NaN)) // NaN
println(ceil(Double.POSITIVE_INFINITY)) // Infinity
println(ceil(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 positive infinity.
Special cases:
ceil(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.2Return
the smallest Float value that is greater than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(ceil(3.14159f)) // 4.0
println(ceil(-1.1f)) // -1.0
// 10.0 is already an "integer", so no rounding will take place
println(ceil(10.0f)) // 10.0
// Special cases
println(ceil(Float.NaN)) // NaN
println(ceil(Float.POSITIVE_INFINITY)) // Infinity
println(ceil(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 positive infinity.
Special cases:
ceil(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.2Return
the smallest double value that is greater than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(ceil(3.14159)) // 4.0
println(ceil(-1.1)) // -1.0
// 10.0 is already an "integer", so no rounding will take place
println(ceil(10.0)) // 10.0
// Special cases
println(ceil(Double.NaN)) // NaN
println(ceil(Double.POSITIVE_INFINITY)) // Infinity
println(ceil(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 positive infinity.
Special cases:
ceil(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.2Return
the smallest Float value that is greater than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(ceil(3.14159f)) // 4.0
println(ceil(-1.1f)) // -1.0
// 10.0 is already an "integer", so no rounding will take place
println(ceil(10.0f)) // 10.0
// Special cases
println(ceil(Float.NaN)) // NaN
println(ceil(Float.POSITIVE_INFINITY)) // Infinity
println(ceil(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 positive infinity.
Special cases:
ceil(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.2Return
the smallest double value that is greater than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(ceil(3.14159)) // 4.0
println(ceil(-1.1)) // -1.0
// 10.0 is already an "integer", so no rounding will take place
println(ceil(10.0)) // 10.0
// Special cases
println(ceil(Double.NaN)) // NaN
println(ceil(Double.POSITIVE_INFINITY)) // Infinity
println(ceil(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 positive infinity.
Special cases:
ceil(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.2Return
the smallest Float value that is greater than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(ceil(3.14159f)) // 4.0
println(ceil(-1.1f)) // -1.0
// 10.0 is already an "integer", so no rounding will take place
println(ceil(10.0f)) // 10.0
// Special cases
println(ceil(Float.NaN)) // NaN
println(ceil(Float.POSITIVE_INFINITY)) // Infinity
println(ceil(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 positive infinity.
Special cases:
ceil(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.3Return
the smallest double value that is greater than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(ceil(3.14159)) // 4.0
println(ceil(-1.1)) // -1.0
// 10.0 is already an "integer", so no rounding will take place
println(ceil(10.0)) // 10.0
// Special cases
println(ceil(Double.NaN)) // NaN
println(ceil(Double.POSITIVE_INFINITY)) // Infinity
println(ceil(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 positive infinity.
Special cases:
ceil(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.3Return
the smallest Float value that is greater than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(ceil(3.14159f)) // 4.0
println(ceil(-1.1f)) // -1.0
// 10.0 is already an "integer", so no rounding will take place
println(ceil(10.0f)) // 10.0
// Special cases
println(ceil(Float.NaN)) // NaN
println(ceil(Float.POSITIVE_INFINITY)) // Infinity
println(ceil(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 positive infinity.
Special cases:
ceil(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.8Return
the smallest double value that is greater than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(ceil(3.14159)) // 4.0
println(ceil(-1.1)) // -1.0
// 10.0 is already an "integer", so no rounding will take place
println(ceil(10.0)) // 10.0
// Special cases
println(ceil(Double.NaN)) // NaN
println(ceil(Double.POSITIVE_INFINITY)) // Infinity
println(ceil(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 positive infinity.
Special cases:
ceil(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.8Return
the smallest Float value that is greater than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(ceil(3.14159f)) // 4.0
println(ceil(-1.1f)) // -1.0
// 10.0 is already an "integer", so no rounding will take place
println(ceil(10.0f)) // 10.0
// Special cases
println(ceil(Float.NaN)) // NaN
println(ceil(Float.POSITIVE_INFINITY)) // Infinity
println(ceil(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 positive infinity.
Special cases:
ceil(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.8Return
the smallest double value that is greater than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(ceil(3.14159)) // 4.0
println(ceil(-1.1)) // -1.0
// 10.0 is already an "integer", so no rounding will take place
println(ceil(10.0)) // 10.0
// Special cases
println(ceil(Double.NaN)) // NaN
println(ceil(Double.POSITIVE_INFINITY)) // Infinity
println(ceil(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 positive infinity.
Special cases:
ceil(x)
isx
wherex
isNaN
or+Inf
or-Inf
or already a mathematical integer.
Since Kotlin
1.8Return
the smallest Float value that is greater than or equal to the given value x and is a mathematical integer.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(ceil(3.14159f)) // 4.0
println(ceil(-1.1f)) // -1.0
// 10.0 is already an "integer", so no rounding will take place
println(ceil(10.0f)) // 10.0
// Special cases
println(ceil(Float.NaN)) // NaN
println(ceil(Float.POSITIVE_INFINITY)) // Infinity
println(ceil(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
}