truncate

Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
fun truncate(x: Double): Double
fun truncate(x: Float): Float

Rounds the given value x to an integer towards zero.

Return

the value x having its fractional part truncated.

Special cases:

  • truncate(x) is x where x is NaN or +Inf or -Inf or already a mathematical integer.

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.math/truncate.html