use .ceil

math.ceil(x).toInt()
Answer from Tenobaal on Stack Overflow
🌐
Kotlin
kotlinlang.org › api › core › kotlin-stdlib › kotlin.math › round.html
round | Core API – Kotlin Programming Language
Rounds the given value x towards the closest integer with ties rounded towards even integer. ... import kotlin.math.* import kotlin.test.* fun main() { //sampleStart println(round(3.49f)) // 3.0 println(round(3.51f)) // 4.0 // 3.5 is between ...
🌐
Baeldung
baeldung.com › home › kotlin › kotlin numbers › rounding numbers in kotlin
Rounding Numbers in Kotlin | Baeldung on Kotlin
September 7, 2024 - Also, we can also specify the rounding mode. For example, using RoundingMode.UP, we can round away from zero.
🌐
Codecademy
codecademy.com › docs › kotlin › math methods › round()
Kotlin | Math Methods | round() | Codecademy
October 27, 2023 - The round() function in Kotlin’s math package rounds a given number to the nearest integer.
🌐
Kotlin
kotlinlang.org › api › core › kotlin-stdlib › kotlin.math › round-to-int.html
roundToInt | Core API – Kotlin Programming Language
x.roundToInt() == Int.MIN_VALUE when x < Int.MIN_VALUE · 1.2 · Illegal · Argument · Exception · when this value is NaN · import kotlin.math.* import kotlin.test.* fun main() { //sampleStart println(3.14159.roundToInt()) // 3 println((-10.0).roundToInt()) // -10 // Values greater than Int.MAX_VALUE are rounded to Int.MAX_VALUE println("(Int.MAX_VALUE.toDouble() + 1.0).roundToInt() == Int.MAX_VALUE is ${(Int.MAX_VALUE.toDouble() + 1.0).roundToInt() == Int.MAX_VALUE}") // true println("Double.POSITIVE_INFINITY.roundToInt() == Int.MAX_VALUE is ${Double.POSITIVE_INFINITY.roundToInt() == Int.M
🌐
Kotlin
kotlinlang.org › api › core › kotlin-stdlib › kotlin.math › ceil.html
ceil | Core API – Kotlin Programming Language
kotlin-stdlib/kotlin.math/ceil · CommonJSJVMNativeWasm-JSWasm-WASI · expect fun ceil(x: Double): Double(source) Rounds the given value x to an integer towards positive infinity.
🌐
Kotlin Discussions
discuss.kotlinlang.org › support
How do you round a number to N decimal places - Support - Kotlin Discussions
August 2, 2018 - So I saw this post about my problem(Print floats with certain amount of decimal numbers) And I was wondering I it possible to use a methood or something else rather “%.2f”.format(value) in order to achive the same thing …
🌐
Kotlin
kotlinlang.org › api › latest › jvm › stdlib › kotlin.math › round-to-int.html
Kotlinlang
Try the revamped Kotlin docs design! ... Mathematical functions and constants. The functions include trigonometric, hyperbolic, exponentiation and power, logarithmic, rounding, sign and absolute value.
🌐
Kotlin
kotlinlang.org › api › latest › jvm › stdlib › kotlin.math › round.html
round
Try the revamped Kotlin docs design! ... Mathematical functions and constants. The functions include trigonometric, hyperbolic, exponentiation and power, logarithmic, rounding, sign and absolute value.
Find elsewhere
🌐
Kotlin
kotlinlang.org › api › core › kotlin-stdlib › kotlin.math › round-to-long.html
roundToLong | Core API – Kotlin Programming Language
x.roundToLong() == Long.MIN_VALUE when x < Long.MIN_VALUE · 1.2 · Illegal · Argument · Exception · when this value is NaN · import kotlin.math.* import kotlin.test.* fun main() { //sampleStart println(3.14159.roundToLong()) // 3 println((-10.0).roundToLong()) // -10 // Values greater than Long.MAX_VALUE are rounded to Long.MAX_VALUE println("(Long.MAX_VALUE.toDouble() * 2.0).roundToLong() == Long.MAX_VALUE is ${(Long.MAX_VALUE.toDouble() * 2.0).roundToLong() == Long.MAX_VALUE}") // true println("Double.POSITIVE_INFINITY.roundToLong() == Long.MAX_VALUE is ${Double.POSITIVE_INFINITY.roundT
🌐
Suneet Agrawal
agrawalsuneet.github.io › blogs › math-round-vs-math-floor-vs-math-ceil-kotlin
Math.round vs Math.floor vs Math.ceil : Kotlin · Suneet Agrawal
April 11, 2022 - Math.round rounds up to the nearest Integer which can be above or below or even equal to the actual value.
🌐
Programiz
programiz.com › kotlin-programming › examples › round-number-decimal
Kotlin Program to Round a Number to n Decimal Places
In the above program, we've used DecimalFormat class to round a given number num. We declare the format using the # patterns #.###. This means, we want num upto 3 decimal places.
🌐
Bbminfo
bbminfo.com › kotlin › library › math › ceil.php
Kotlin ceil() - Kotlin Math Functions - bbminfo
The Kotlin Math.ceil() function returns the next highest integer value by rounding up value of a floating poing number if necessary.
🌐
Kotlin
kotlinlang.org › api › latest › jvm › stdlib › kotlin.math › ceil.html
ceil - Kotlin Programming Language
August 10, 2022 - Try the revamped Kotlin docs design! ... Mathematical functions and constants. The functions include trigonometric, hyperbolic, exponentiation and power, logarithmic, rounding, sign and absolute value.
🌐
Android Developers
developer.android.com › api reference › roundingmode
RoundingMode | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
Kotlinlang
slack-chats.kotlinlang.org › t › 474887 › what-is-the-most-efficient-way-to-round-double-up-to-certain
what is the most efficient way to round `Double` up to certa kotlinlang #getting-started
September 17, 2021 - HALF_ are exactly about dealing with ties (e.g. when it's exactly 1.5), but it's not the case here. You could of course set the rounding mode to · UP but in that case even 1.0001 will be rounded to 2.
🌐
Codecademy
codecademy.com › docs › kotlin › math methods › ceil()
Kotlin | Math Methods | ceil() | Codecademy
October 26, 2023 - The ceil() method in Kotlin’s math library rounds a floating-point number up to the nearest integer.