← Docs
kotlin-stdlib / kotlin.math / truncate

truncate

Common
JVM
JS
Native
1.2
fun truncate ( x : Double ) : Double
(Common source) (JVM source) (JS source) (Native source)
fun truncate ( x : Float ) : Float
(Common source) (JVM source) (JS source) (Native source)

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.

Stay in touch:
  • Contributing to Kotlin
  • Releases
  • Press Kit
  • Security
  • Blog
  • Issue Tracker
  • Brand assets
  • Careers
Supported and developed by JetBrains .
Kotlin™ is protected under the Kotlin Foundation
and licensed under the Apache 2 license .