<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Double/maximum(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SFsE7maximumyxx_xtFZ::SYNTHESIZED::s:Sd"
  },
  "title" : "maximum(_:_:)"
}
-->

# maximum(_:_:)

Returns the greater of the two given values.

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

## Parameters

`x`

A floating-point value.

`y`

Another floating-point value.

## Return Value

The greater of `x` and `y`, or whichever is a number if the
other is NaN.

## Discussion

This method returns the maximum of two values, preserving order and
eliminating NaN when possible. For two values `x` and `y`, the result of
`maximum(x, y)` is `x` if `x > y`, `y` if `x <= y`, 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.maximum(10.0, -25.0)
// 10.0
Double.maximum(10.0, .nan)
// 10.0
Double.maximum(.nan, -25.0)
// -25.0
Double.maximum(.nan, .nan)
// nan
```

The `maximum` method implements the `maxNum` operation defined by the
[IEEE 754 specification](http://ieeexplore.ieee.org/servlet/opac?punumber=4610933).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)