abs
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
fun abs(x: Double): Double
fun abs(x: Float): Float
Returns the absolute value of the given value x.
Special cases:
-
abs(NaN)
isNaN
See Also
absoluteValue
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
fun abs(n: Int): Int
Returns the absolute value of the given value n.
Special cases:
-
abs(Int.MIN_VALUE)
isInt.MIN_VALUE
due to an overflow
See Also
absoluteValue
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
fun abs(n: Long): Long
Returns the absolute value of the given value n.
Special cases:
-
abs(Long.MIN_VALUE)
isLong.MIN_VALUE
due to an overflow
See Also
absoluteValue
© 2010–2021 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/abs.html