<!--
{
  "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/NSSwapHostLongToBig(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@F@NSSwapHostLongToBig"
  },
  "title" : "NSSwapHostLongToBig(_:)"
}
-->

# NSSwapHostLongToBig(_:)

Swaps the bytes of a number.

```
func NSSwapHostLongToBig(_ x: UInt) -> UInt
```

## Discussion

Converts the value in `x`, specified in the current endian format, to big-endian format and returns the resulting value. If it is necessary to swap the bytes, this function calls [`NSSwapLong(_:)`](/documentation/Foundation/NSSwapLong(_:)) to perform the swap.

## See Also

[`func NSSwapHostLongToLittle(UInt) -> UInt`](/documentation/Foundation/NSSwapHostLongToLittle(_:))

Swaps the bytes of a number.

[`func NSSwapBigLongToHost(UInt) -> UInt`](/documentation/Foundation/NSSwapBigLongToHost(_:))

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)