truncate

expect fun truncate(x: Double): Double(source)
expect fun truncate(x: Float): Float(source)

Rounds the given value x to an integer towards zero.

Since Kotlin

1.2

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.

actual inline fun truncate(x: Double): Double(source)
actual inline fun truncate(x: Float): Float(source)

Rounds the given value x to an integer towards zero.

Since Kotlin

1.2

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.

actual fun truncate(x: Double): Double(source)
actual fun truncate(x: Float): Float(source)

Rounds the given value x to an integer towards zero.

Since Kotlin

1.2

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.

actual fun truncate(x: Double): Double(source)
actual fun truncate(x: Float): Float(source)

Rounds the given value x to an integer towards zero.

Since Kotlin

1.3

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.