ceil()
Anonymous contributor
Anonymous contributor1 total contribution
Anonymous contributor
Published Oct 26, 2023
Contribute to Docs
The ceil()
method in Kotlin’s math
library rounds a floating-point number up to the nearest integer.
Syntax
kotlin.math.ceil(x)
x
: A value of typeDouble
orFloat
to be rounded up.
Example
The following code demonstrates a basic implementation of the ceil()
method.
val myDouble: Double = 7.5val myFloat: Float = 6.3fval myInt: Int = 4val resultDouble: Double = ceil(myDouble)val resultFloat: Float = ceil(myFloat)val resultInt: Double = ceil(myInt.toDouble())fun main() {println(resultDouble)println(resultFloat)println(resultInt)}
This will return the following output:
8.07.04.0
All contributors
- Anonymous contributorAnonymous contributor1 total contribution
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.