func squareRoot () -> Self
Returns the square root of the value, rounded to a representable value.
この値の平方根を返します、表現可能な値に丸められます。
Availability
Technology
func squareRoot() -> Self
The square root of the value. この値の平方根。
The following example declares a function that calculates the length of the hypotenuse of a right triangle given its two perpendicular sides. 以下の例はある関数を宣言します、それは、それの2つの直角側を与えられる直角三角形の斜辺の長さを計算します。
func hypotenuse(_ a: Double, _ b: Double) -> Double {
return (a * a + b * b).squareRoot()
}
let (dx, dy) = (3.0, 4.0)
let distance = hypotenuse(dx, dy)
// distance == 5.0
func squareRoot () -> Self