---
title: "distance(to:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/double/distance(to:)"
---

# distance(to:)

Returns the distance from this value to the given value, expressed as a stride.

## Declaration

```swift
func distance(to other: Double) -> Double
```

## Parameters

- `other`: The value to calculate the distance to.

## Return Value

Return Value The distance from this value to other.

## Discussion

Discussion If this type’s Stride type conforms to BinaryInteger, then for two values x and y, and a distance n = x.distance(to: y), x.advanced(by: n) == y. Using this method with types that have a noninteger Stride may result in an approximation. note: O(1)

## See Also

### Infrequently Used Functionality

- [init()](swift/double/init().md)
- [init(floatLiteral:)](swift/double/init(floatliteral:).md)
- [init(integerLiteral:)](swift/double/init(integerliteral:).md)
- [init(integerLiteral:)](swift/double/init(integerliteral:)-6hc7j.md)
- [Double.FloatLiteralType](swift/double/floatliteraltype.md)
- [Double.IntegerLiteralType](swift/double/integerliteraltype.md)
- [advanced(by:)](swift/double/advanced(by:).md)
- [Double.Stride](swift/double/stride.md)
- [write(to:)](swift/double/write(to:).md)
- [hashValue](swift/double/hashvalue.md)
