<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSSwapDouble(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@F@NSSwapDouble"
  },
  "title" : "NSSwapDouble(_:)"
}
-->

# NSSwapDouble(_:)

Swaps the bytes of a number.

```
func NSSwapDouble(_ x: NSSwappedDouble) -> NSSwappedDouble
```

## Discussion

Swaps the bytes of `x` and returns the resulting value. Bytes are swapped from each low-order position to the corresponding high-order position and vice versa. For example, if the bytes of `x` are numbered from 1 to 8, this function swaps bytes 1 and 8, bytes 2 and 7, bytes 3 and 6, and bytes 4 and 5.

## See Also

[`func NSSwapLongLong(UInt64) -> UInt64`](/documentation/Foundation/NSSwapLongLong(_:))

Swaps the bytes of a number.

[`func NSSwapFloat(NSSwappedFloat) -> NSSwappedFloat`](/documentation/Foundation/NSSwapFloat(_:))

Swaps the bytes of a number.



---

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)