---
title: "advanced(by:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/float/advanced(by:)"
---

# advanced(by:)

Returns a value that is offset the specified distance from this value.

## Declaration

```swift
func advanced(by amount: Float) -> Float
```

## Return Value

Return Value A value that is offset from this value by n.

## Discussion

Discussion Use the advanced(by:) method in generic code to offset a value by a specified distance. If you’re working directly with numeric values, use the addition operator (+) instead of this method. func addOne<T: Strideable>(to x: T) -> T     where T.Stride: ExpressibleByIntegerLiteral {     return x.advanced(by: 1) }

let x = addOne(to: 5) // x == 6 let y = addOne(to: 3.5) // y = 4.5 If this type’s Stride type conforms to BinaryInteger, then for a value x, a distance n, and a value y = x.advanced(by: n), x.distance(to: y) == n. Using this method with types that have a noninteger Stride may result in an approximation. If the result of advancing by n is not representable as a value of this type, then a runtime error may occur. note: O(1)

## See Also

### Infrequently Used Functionality

- [init()](swift/float/init().md)
- [init(integerLiteral:)](swift/float/init(integerliteral:).md)
- [init(floatLiteral:)](swift/float/init(floatliteral:).md)
- [init(integerLiteral:)](swift/float/init(integerliteral:)-6hc7h.md)
- [distance(to:)](swift/float/distance(to:).md)
- [write(to:)](swift/float/write(to:).md)
