---
title: squareRoot()
framework: swift
role: symbol
role_heading: Instance Method
path: swift/double/squareroot()
---

# squareRoot()

Returns the square root of the value, rounded to a representable value.

## Declaration

```swift
func squareRoot() -> Self
```

## Return Value

Return Value The square root of the value.

## Discussion

Discussion The following example declares a function that calculates the length of the hypotenuse of a right triangle given its two perpendicular sides. 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

## See Also

### Performing Calculations

- [Floating-Point Operators for Double](swift/floating-point-operators-for-double.md)
- [addingProduct(_:_:)](swift/double/addingproduct(_:_:).md)
- [addProduct(_:_:)](swift/double/addproduct(_:_:).md)
- [formSquareRoot()](swift/double/formsquareroot().md)
- [remainder(dividingBy:)](swift/double/remainder(dividingby:).md)
- [formRemainder(dividingBy:)](swift/double/formremainder(dividingby:).md)
- [truncatingRemainder(dividingBy:)](swift/double/truncatingremainder(dividingby:).md)
- [formTruncatingRemainder(dividingBy:)](swift/double/formtruncatingremainder(dividingby:).md)
- [negate()](swift/double/negate().md)
