---
title: "maximumMagnitude(_:_:)"
framework: swift
role: symbol
role_heading: Type Method
path: "swift/float/maximummagnitude(_:_:)"
---

# maximumMagnitude(_:_:)

Returns the value with greater magnitude.

## Declaration

```swift
static func maximumMagnitude(_ x: Self, _ y: Self) -> Self
```

## Parameters

- `x`: A floating-point value.
- `y`: Another floating-point value.

## Return Value

Return Value Whichever of x or y has greater magnitude, or whichever is a number if the other is NaN.

## Discussion

Discussion This method returns the value with greater magnitude of the two given values, preserving order and eliminating NaN when possible. For two values x and y, the result of maximumMagnitude(x, y) is x if x.magnitude > y.magnitude, y if x.magnitude <= y.magnitude, or whichever of x or y is a number if the other is a quiet NaN. If both x and y are NaN, or either x or y is a signaling NaN, the result is NaN. Double.maximumMagnitude(10.0, -25.0) // -25.0 Double.maximumMagnitude(10.0, .nan) // 10.0 Double.maximumMagnitude(.nan, -25.0) // -25.0 Double.maximumMagnitude(.nan, .nan) // nan The maximumMagnitude method implements the maxNumMag operation defined by the IEEE 754 specification.

## See Also

### Comparing Values

- [Floating-Point Operators for Float](swift/floating-point-operators-for-float.md)
- [isEqual(to:)](swift/float/isequal(to:).md)
- [isLess(than:)](swift/float/isless(than:).md)
- [isLessThanOrEqualTo(_:)](swift/float/islessthanorequalto(_:).md)
- [isTotallyOrdered(belowOrEqualTo:)](swift/float/istotallyordered(beloworequalto:).md)
- [maximum(_:_:)](swift/float/maximum(_:_:).md)
- [minimum(_:_:)](swift/float/minimum(_:_:).md)
- [minimumMagnitude(_:_:)](swift/float/minimummagnitude(_:_:).md)
