truncate

expect fun truncate(x: Double): Double
expect 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.

Since Kotlin

1.2
actual fun truncate(x: Double): Double
actual 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.

Since Kotlin

1.2
actual inline fun truncate(x: Double): Double
actual inline 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.

Since Kotlin

1.2
actual fun truncate(x: Double): Double
actual 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.

Since Kotlin

1.2