absoluteValue
Returns the absolute value of this value.
Special cases:
NaN.absoluteValueisNaN
Since Kotlin
1.2See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.absoluteValue) // 3.14
println((-3.14).absoluteValue) // 3.14
println((-0.0).absoluteValue) // 0.0
println(Double.NEGATIVE_INFINITY.absoluteValue) // Infinity
println(Double.NaN.absoluteValue) // NaN
//sampleEnd
}Returns the absolute value of this value.
Special cases:
NaN.absoluteValueisNaN
Since Kotlin
1.2See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.absoluteValue) // 3.14
println((-3.14f).absoluteValue) // 3.14
println((-0.0f).absoluteValue) // 0.0
println(Float.NEGATIVE_INFINITY.absoluteValue) // Infinity
println(Float.NaN.absoluteValue) // NaN
//sampleEnd
}Returns the absolute value of this value.
Special cases:
Int.MIN_VALUE.absoluteValueisInt.MIN_VALUEdue to an overflow
Since Kotlin
1.2See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(42.absoluteValue) // 42
println((-42).absoluteValue) // 42
// Special case: can't get the absolute value due to an overflow
println("Int.MIN_VALUE.absoluteValue == Int.MIN_VALUE is ${Int.MIN_VALUE.absoluteValue == Int.MIN_VALUE}") // true
//sampleEnd
}Returns the absolute value of this value.
Special cases:
Long.MIN_VALUE.absoluteValueisLong.MIN_VALUEdue to an overflow
Since Kotlin
1.2See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(42L.absoluteValue) // 42
println((-42L).absoluteValue) // 42
// Special case: can't get the absolute value due to an overflow
println("Long.MIN_VALUE.absoluteValue == Long.MIN_VALUE is ${Long.MIN_VALUE.absoluteValue == Long.MIN_VALUE}") // true
//sampleEnd
}Returns the absolute value of this value.
Special cases:
NaN.absoluteValueisNaN
Since Kotlin
1.2See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.absoluteValue) // 3.14
println((-3.14).absoluteValue) // 3.14
println((-0.0).absoluteValue) // 0.0
println(Double.NEGATIVE_INFINITY.absoluteValue) // Infinity
println(Double.NaN.absoluteValue) // NaN
//sampleEnd
}Returns the absolute value of this value.
Special cases:
NaN.absoluteValueisNaN
Since Kotlin
1.2See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.absoluteValue) // 3.14
println((-3.14f).absoluteValue) // 3.14
println((-0.0f).absoluteValue) // 0.0
println(Float.NEGATIVE_INFINITY.absoluteValue) // Infinity
println(Float.NaN.absoluteValue) // NaN
//sampleEnd
}Returns the absolute value of this value.
Special cases:
Int.MIN_VALUE.absoluteValueisInt.MIN_VALUEdue to an overflow
Since Kotlin
1.2See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(42.absoluteValue) // 42
println((-42).absoluteValue) // 42
// Special case: can't get the absolute value due to an overflow
println("Int.MIN_VALUE.absoluteValue == Int.MIN_VALUE is ${Int.MIN_VALUE.absoluteValue == Int.MIN_VALUE}") // true
//sampleEnd
}Returns the absolute value of this value.
Special cases:
Long.MIN_VALUE.absoluteValueisLong.MIN_VALUEdue to an overflow
Since Kotlin
1.2See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(42L.absoluteValue) // 42
println((-42L).absoluteValue) // 42
// Special case: can't get the absolute value due to an overflow
println("Long.MIN_VALUE.absoluteValue == Long.MIN_VALUE is ${Long.MIN_VALUE.absoluteValue == Long.MIN_VALUE}") // true
//sampleEnd
}Returns the absolute value of this value.
Special cases:
NaN.absoluteValueisNaN
Since Kotlin
1.2See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.absoluteValue) // 3.14
println((-3.14).absoluteValue) // 3.14
println((-0.0).absoluteValue) // 0.0
println(Double.NEGATIVE_INFINITY.absoluteValue) // Infinity
println(Double.NaN.absoluteValue) // NaN
//sampleEnd
}Returns the absolute value of this value.
Special cases:
NaN.absoluteValueisNaN
Since Kotlin
1.2See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.absoluteValue) // 3.14
println((-3.14f).absoluteValue) // 3.14
println((-0.0f).absoluteValue) // 0.0
println(Float.NEGATIVE_INFINITY.absoluteValue) // Infinity
println(Float.NaN.absoluteValue) // NaN
//sampleEnd
}Returns the absolute value of this value.
Special cases:
Int.MIN_VALUE.absoluteValueisInt.MIN_VALUEdue to an overflow
Since Kotlin
1.2See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(42.absoluteValue) // 42
println((-42).absoluteValue) // 42
// Special case: can't get the absolute value due to an overflow
println("Int.MIN_VALUE.absoluteValue == Int.MIN_VALUE is ${Int.MIN_VALUE.absoluteValue == Int.MIN_VALUE}") // true
//sampleEnd
}Returns the absolute value of this value.
Special cases:
Long.MIN_VALUE.absoluteValueisLong.MIN_VALUEdue to an overflow
Since Kotlin
1.2See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(42L.absoluteValue) // 42
println((-42L).absoluteValue) // 42
// Special case: can't get the absolute value due to an overflow
println("Long.MIN_VALUE.absoluteValue == Long.MIN_VALUE is ${Long.MIN_VALUE.absoluteValue == Long.MIN_VALUE}") // true
//sampleEnd
}Returns the absolute value of this value.
Special cases:
NaN.absoluteValueisNaN
Since Kotlin
1.3See also
actual function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.absoluteValue) // 3.14
println((-3.14).absoluteValue) // 3.14
println((-0.0).absoluteValue) // 0.0
println(Double.NEGATIVE_INFINITY.absoluteValue) // Infinity
println(Double.NaN.absoluteValue) // NaN
//sampleEnd
}Returns the absolute value of this value.
Special cases:
NaN.absoluteValueisNaN
Since Kotlin
1.3See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.absoluteValue) // 3.14
println((-3.14f).absoluteValue) // 3.14
println((-0.0f).absoluteValue) // 0.0
println(Float.NEGATIVE_INFINITY.absoluteValue) // Infinity
println(Float.NaN.absoluteValue) // NaN
//sampleEnd
}Returns the absolute value of this value.
Special cases:
Int.MIN_VALUE.absoluteValueisInt.MIN_VALUEdue to an overflow
Since Kotlin
1.3See also
actual function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(42.absoluteValue) // 42
println((-42).absoluteValue) // 42
// Special case: can't get the absolute value due to an overflow
println("Int.MIN_VALUE.absoluteValue == Int.MIN_VALUE is ${Int.MIN_VALUE.absoluteValue == Int.MIN_VALUE}") // true
//sampleEnd
}Returns the absolute value of this value.
Special cases:
Long.MIN_VALUE.absoluteValueisLong.MIN_VALUEdue to an overflow
Since Kotlin
1.3See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(42L.absoluteValue) // 42
println((-42L).absoluteValue) // 42
// Special case: can't get the absolute value due to an overflow
println("Long.MIN_VALUE.absoluteValue == Long.MIN_VALUE is ${Long.MIN_VALUE.absoluteValue == Long.MIN_VALUE}") // true
//sampleEnd
}Returns the absolute value of this value.
Special cases:
NaN.absoluteValueisNaN
Since Kotlin
1.8See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.absoluteValue) // 3.14
println((-3.14).absoluteValue) // 3.14
println((-0.0).absoluteValue) // 0.0
println(Double.NEGATIVE_INFINITY.absoluteValue) // Infinity
println(Double.NaN.absoluteValue) // NaN
//sampleEnd
}Returns the absolute value of this value.
Special cases:
NaN.absoluteValueisNaN
Since Kotlin
1.8See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.absoluteValue) // 3.14
println((-3.14f).absoluteValue) // 3.14
println((-0.0f).absoluteValue) // 0.0
println(Float.NEGATIVE_INFINITY.absoluteValue) // Infinity
println(Float.NaN.absoluteValue) // NaN
//sampleEnd
}Returns the absolute value of this value.
Special cases:
Int.MIN_VALUE.absoluteValueisInt.MIN_VALUEdue to an overflow
Since Kotlin
1.8See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(42.absoluteValue) // 42
println((-42).absoluteValue) // 42
// Special case: can't get the absolute value due to an overflow
println("Int.MIN_VALUE.absoluteValue == Int.MIN_VALUE is ${Int.MIN_VALUE.absoluteValue == Int.MIN_VALUE}") // true
//sampleEnd
}Returns the absolute value of this value.
Special cases:
Long.MIN_VALUE.absoluteValueisLong.MIN_VALUEdue to an overflow
Since Kotlin
1.8See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(42L.absoluteValue) // 42
println((-42L).absoluteValue) // 42
// Special case: can't get the absolute value due to an overflow
println("Long.MIN_VALUE.absoluteValue == Long.MIN_VALUE is ${Long.MIN_VALUE.absoluteValue == Long.MIN_VALUE}") // true
//sampleEnd
}Returns the absolute value of this value.
Special cases:
NaN.absoluteValueisNaN
Since Kotlin
1.8See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14.absoluteValue) // 3.14
println((-3.14).absoluteValue) // 3.14
println((-0.0).absoluteValue) // 0.0
println(Double.NEGATIVE_INFINITY.absoluteValue) // Infinity
println(Double.NaN.absoluteValue) // NaN
//sampleEnd
}Returns the absolute value of this value.
Special cases:
NaN.absoluteValueisNaN
Since Kotlin
1.8See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(3.14f.absoluteValue) // 3.14
println((-3.14f).absoluteValue) // 3.14
println((-0.0f).absoluteValue) // 0.0
println(Float.NEGATIVE_INFINITY.absoluteValue) // Infinity
println(Float.NaN.absoluteValue) // NaN
//sampleEnd
}Returns the absolute value of this value.
Special cases:
Int.MIN_VALUE.absoluteValueisInt.MIN_VALUEdue to an overflow
Since Kotlin
1.8See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(42.absoluteValue) // 42
println((-42).absoluteValue) // 42
// Special case: can't get the absolute value due to an overflow
println("Int.MIN_VALUE.absoluteValue == Int.MIN_VALUE is ${Int.MIN_VALUE.absoluteValue == Int.MIN_VALUE}") // true
//sampleEnd
}Returns the absolute value of this value.
Special cases:
Long.MIN_VALUE.absoluteValueisLong.MIN_VALUEdue to an overflow
Since Kotlin
1.8See also
function
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(42L.absoluteValue) // 42
println((-42L).absoluteValue) // 42
// Special case: can't get the absolute value due to an overflow
println("Long.MIN_VALUE.absoluteValue == Long.MIN_VALUE is ${Long.MIN_VALUE.absoluteValue == Long.MIN_VALUE}") // true
//sampleEnd
}