hypot
Computes sqrt(x^2 + y^2) without intermediate overflow or underflow.
Special cases:
returns
+Infif any of arguments is infinitereturns
NaNif any of arguments isNaNand the other is not infinite
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
// sqrt(6 * 6 + 8 * 8) = sqrt(36 + 64) = sqrt(100) = 10
println(hypot(6.0, 8.0)) // 10.0
// special cases
println(hypot(Double.NaN, 2.0)) // NaN
println(hypot(1.0, Double.NaN)) // NaN
println(hypot(Double.POSITIVE_INFINITY, 2.0)) // Infinity
println(hypot(1.0, Double.NEGATIVE_INFINITY)) // Infinity
//sampleEnd
}Computes sqrt(x^2 + y^2) without intermediate overflow or underflow.
Special cases:
returns
+Infif any of arguments is infinitereturns
NaNif any of arguments isNaNand the other is not infinite
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
// sqrt(6 * 6 + 8 * 8) = sqrt(36 + 64) = sqrt(100) = 10
println(hypot(6.0f, 8.0f)) // 10.0
// special cases
println(hypot(Float.NaN, 2.0f)) // NaN
println(hypot(1.0f, Float.NaN)) // NaN
println(hypot(Float.POSITIVE_INFINITY, 2.0f)) // Infinity
println(hypot(1.0f, Float.NEGATIVE_INFINITY)) // Infinity
//sampleEnd
}Computes sqrt(x^2 + y^2) without intermediate overflow or underflow.
Special cases:
returns
+Infif any of arguments is infinitereturns
NaNif any of arguments isNaNand the other is not infinite
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
// sqrt(6 * 6 + 8 * 8) = sqrt(36 + 64) = sqrt(100) = 10
println(hypot(6.0, 8.0)) // 10.0
// special cases
println(hypot(Double.NaN, 2.0)) // NaN
println(hypot(1.0, Double.NaN)) // NaN
println(hypot(Double.POSITIVE_INFINITY, 2.0)) // Infinity
println(hypot(1.0, Double.NEGATIVE_INFINITY)) // Infinity
//sampleEnd
}Computes sqrt(x^2 + y^2) without intermediate overflow or underflow.
Special cases:
returns
+Infif any of arguments is infinitereturns
NaNif any of arguments isNaNand the other is not infinite
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
// sqrt(6 * 6 + 8 * 8) = sqrt(36 + 64) = sqrt(100) = 10
println(hypot(6.0f, 8.0f)) // 10.0
// special cases
println(hypot(Float.NaN, 2.0f)) // NaN
println(hypot(1.0f, Float.NaN)) // NaN
println(hypot(Float.POSITIVE_INFINITY, 2.0f)) // Infinity
println(hypot(1.0f, Float.NEGATIVE_INFINITY)) // Infinity
//sampleEnd
}Computes sqrt(x^2 + y^2) without intermediate overflow or underflow.
Special cases:
returns
+Infif any of arguments is infinitereturns
NaNif any of arguments isNaNand the other is not infinite
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
// sqrt(6 * 6 + 8 * 8) = sqrt(36 + 64) = sqrt(100) = 10
println(hypot(6.0, 8.0)) // 10.0
// special cases
println(hypot(Double.NaN, 2.0)) // NaN
println(hypot(1.0, Double.NaN)) // NaN
println(hypot(Double.POSITIVE_INFINITY, 2.0)) // Infinity
println(hypot(1.0, Double.NEGATIVE_INFINITY)) // Infinity
//sampleEnd
}Computes sqrt(x^2 + y^2) without intermediate overflow or underflow.
Special cases:
returns
+Infif any of arguments is infinitereturns
NaNif any of arguments isNaNand the other is not infinite
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
// sqrt(6 * 6 + 8 * 8) = sqrt(36 + 64) = sqrt(100) = 10
println(hypot(6.0f, 8.0f)) // 10.0
// special cases
println(hypot(Float.NaN, 2.0f)) // NaN
println(hypot(1.0f, Float.NaN)) // NaN
println(hypot(Float.POSITIVE_INFINITY, 2.0f)) // Infinity
println(hypot(1.0f, Float.NEGATIVE_INFINITY)) // Infinity
//sampleEnd
}Computes sqrt(x^2 + y^2) without intermediate overflow or underflow.
Special cases:
returns
+Infif any of arguments is infinitereturns
NaNif any of arguments isNaNand the other is not infinite
Since Kotlin
1.3Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
// sqrt(6 * 6 + 8 * 8) = sqrt(36 + 64) = sqrt(100) = 10
println(hypot(6.0, 8.0)) // 10.0
// special cases
println(hypot(Double.NaN, 2.0)) // NaN
println(hypot(1.0, Double.NaN)) // NaN
println(hypot(Double.POSITIVE_INFINITY, 2.0)) // Infinity
println(hypot(1.0, Double.NEGATIVE_INFINITY)) // Infinity
//sampleEnd
}Computes sqrt(x^2 + y^2) without intermediate overflow or underflow.
Special cases:
returns
+Infif any of arguments is infinitereturns
NaNif any of arguments isNaNand the other is not infinite
Since Kotlin
1.3Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
// sqrt(6 * 6 + 8 * 8) = sqrt(36 + 64) = sqrt(100) = 10
println(hypot(6.0f, 8.0f)) // 10.0
// special cases
println(hypot(Float.NaN, 2.0f)) // NaN
println(hypot(1.0f, Float.NaN)) // NaN
println(hypot(Float.POSITIVE_INFINITY, 2.0f)) // Infinity
println(hypot(1.0f, Float.NEGATIVE_INFINITY)) // Infinity
//sampleEnd
}Computes sqrt(x^2 + y^2) without intermediate overflow or underflow.
Special cases:
returns
+Infif any of arguments is infinitereturns
NaNif any of arguments isNaNand the other is not infinite
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
// sqrt(6 * 6 + 8 * 8) = sqrt(36 + 64) = sqrt(100) = 10
println(hypot(6.0, 8.0)) // 10.0
// special cases
println(hypot(Double.NaN, 2.0)) // NaN
println(hypot(1.0, Double.NaN)) // NaN
println(hypot(Double.POSITIVE_INFINITY, 2.0)) // Infinity
println(hypot(1.0, Double.NEGATIVE_INFINITY)) // Infinity
//sampleEnd
}Computes sqrt(x^2 + y^2) without intermediate overflow or underflow.
Special cases:
returns
+Infif any of arguments is infinitereturns
NaNif any of arguments isNaNand the other is not infinite
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
// sqrt(6 * 6 + 8 * 8) = sqrt(36 + 64) = sqrt(100) = 10
println(hypot(6.0f, 8.0f)) // 10.0
// special cases
println(hypot(Float.NaN, 2.0f)) // NaN
println(hypot(1.0f, Float.NaN)) // NaN
println(hypot(Float.POSITIVE_INFINITY, 2.0f)) // Infinity
println(hypot(1.0f, Float.NEGATIVE_INFINITY)) // Infinity
//sampleEnd
}Computes sqrt(x^2 + y^2) without intermediate overflow or underflow.
Special cases:
returns
+Infif any of arguments is infinitereturns
NaNif any of arguments isNaNand the other is not infinite
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
// sqrt(6 * 6 + 8 * 8) = sqrt(36 + 64) = sqrt(100) = 10
println(hypot(6.0, 8.0)) // 10.0
// special cases
println(hypot(Double.NaN, 2.0)) // NaN
println(hypot(1.0, Double.NaN)) // NaN
println(hypot(Double.POSITIVE_INFINITY, 2.0)) // Infinity
println(hypot(1.0, Double.NEGATIVE_INFINITY)) // Infinity
//sampleEnd
}Computes sqrt(x^2 + y^2) without intermediate overflow or underflow.
Special cases:
returns
+Infif any of arguments is infinitereturns
NaNif any of arguments isNaNand the other is not infinite
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
// sqrt(6 * 6 + 8 * 8) = sqrt(36 + 64) = sqrt(100) = 10
println(hypot(6.0f, 8.0f)) // 10.0
// special cases
println(hypot(Float.NaN, 2.0f)) // NaN
println(hypot(1.0f, Float.NaN)) // NaN
println(hypot(Float.POSITIVE_INFINITY, 2.0f)) // Infinity
println(hypot(1.0f, Float.NEGATIVE_INFINITY)) // Infinity
//sampleEnd
}