<!--
{
  "documentType" : "article",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/byte-order-utilities",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Byte-Order Utilities"
}
-->

# Byte-Order Utilities

## Overview

When handling binary data transmitted or shared across platforms, you need be concerned with how each platform stores numerical values. A platform stores values either in big-endian or little-endian format. On big-endian machines, such as PowerPC machines, values are stored with the most-significant bytes first in memory; on little-endian machines, such as Pentium machines, values are stored with the least-significant bytes first. A multibyte value transmitted to a platform with a different format will be misinterpreted if it is not converted properly by one of the computers.

You identify the native format of the current platform using the [`CFByteOrderGetCurrent()`](/documentation/CoreFoundation/CFByteOrderGetCurrent()) function. Use functions such as [`CFSwapInt32BigToHost(_:)`](/documentation/CoreFoundation/CFSwapInt32BigToHost(_:)) and [`CFConvertFloat32HostToSwapped(_:)`](/documentation/CoreFoundation/CFConvertFloat32HostToSwapped(_:)) to convert values between different byte order formats.

## Topics

### Core Foundation Byte Order Utilities Miscellaneous Functions

[`CFByteOrderGetCurrent()`](/documentation/CoreFoundation/CFByteOrderGetCurrent())

Returns the byte order of the current computer.

[`CFConvertDoubleHostToSwapped(_:)`](/documentation/CoreFoundation/CFConvertDoubleHostToSwapped(_:))

Converts a 64-bit double from the host’s native byte order to a platform-independent format.

[`CFConvertDoubleSwappedToHost(_:)`](/documentation/CoreFoundation/CFConvertDoubleSwappedToHost(_:))

Converts a 64-bit double from a platform-independent format to the host’s native byte order.

[`CFConvertFloat32HostToSwapped(_:)`](/documentation/CoreFoundation/CFConvertFloat32HostToSwapped(_:))

Converts a 32-bit float from the host’s native byte order to a platform-independent format.

[`CFConvertFloat32SwappedToHost(_:)`](/documentation/CoreFoundation/CFConvertFloat32SwappedToHost(_:))

Converts a 32-bit float from a platform-independent format to the host’s native byte order.

[`CFConvertFloat64HostToSwapped(_:)`](/documentation/CoreFoundation/CFConvertFloat64HostToSwapped(_:))

Converts a 64-bit float from the host’s native byte order to a platform-independent format.

[`CFConvertFloat64SwappedToHost(_:)`](/documentation/CoreFoundation/CFConvertFloat64SwappedToHost(_:))

Converts a 64-bit float from a platform-independent format to the host’s native byte order.

[`CFConvertFloatHostToSwapped(_:)`](/documentation/CoreFoundation/CFConvertFloatHostToSwapped(_:))

Converts a 32-bit float from the host’s native byte order to a platform-independent format.

[`CFConvertFloatSwappedToHost(_:)`](/documentation/CoreFoundation/CFConvertFloatSwappedToHost(_:))

Converts a 32-bit float from a platform-independent format to the host’s native byte order.

[`CFSwapInt16(_:)`](/documentation/CoreFoundation/CFSwapInt16(_:))

Swaps the bytes of a 16-bit integer.

[`CFSwapInt16BigToHost(_:)`](/documentation/CoreFoundation/CFSwapInt16BigToHost(_:))

Converts a 16-bit integer from big-endian format to the host’s native byte order.

[`CFSwapInt16HostToBig(_:)`](/documentation/CoreFoundation/CFSwapInt16HostToBig(_:))

Converts a 16-bit integer from the host’s native byte order to big-endian format.

[`CFSwapInt16HostToLittle(_:)`](/documentation/CoreFoundation/CFSwapInt16HostToLittle(_:))

Converts a 16-bit integer from the host’s native byte order to little-endian format.

[`CFSwapInt16LittleToHost(_:)`](/documentation/CoreFoundation/CFSwapInt16LittleToHost(_:))

Converts a 16-bit integer from little-endian format to the host’s native byte order.

[`CFSwapInt32(_:)`](/documentation/CoreFoundation/CFSwapInt32(_:))

Swaps the bytes of a 32-bit integer.

[`CFSwapInt32BigToHost(_:)`](/documentation/CoreFoundation/CFSwapInt32BigToHost(_:))

Converts a 32-bit integer from big-endian format to the host’s native byte order.

[`CFSwapInt32HostToBig(_:)`](/documentation/CoreFoundation/CFSwapInt32HostToBig(_:))

Converts a 32-bit integer from the host’s native byte order to big-endian format.

[`CFSwapInt32HostToLittle(_:)`](/documentation/CoreFoundation/CFSwapInt32HostToLittle(_:))

Converts a 32-bit integer from the host’s native byte order to little-endian format.

[`CFSwapInt32LittleToHost(_:)`](/documentation/CoreFoundation/CFSwapInt32LittleToHost(_:))

Converts a 32-bit integer from little-endian format to the host’s native byte order.

[`CFSwapInt64(_:)`](/documentation/CoreFoundation/CFSwapInt64(_:))

Swaps the bytes of a 64-bit integer.

[`CFSwapInt64BigToHost(_:)`](/documentation/CoreFoundation/CFSwapInt64BigToHost(_:))

Converts a 64-bit integer from big-endian format to the host’s native byte order.

[`CFSwapInt64HostToBig(_:)`](/documentation/CoreFoundation/CFSwapInt64HostToBig(_:))

Converts a 64-bit integer from the host’s native byte order to big-endian format.

[`CFSwapInt64HostToLittle(_:)`](/documentation/CoreFoundation/CFSwapInt64HostToLittle(_:))

Converts a 64-bit integer from the host’s native byte order to little-endian format.

[`CFSwapInt64LittleToHost(_:)`](/documentation/CoreFoundation/CFSwapInt64LittleToHost(_:))

Converts a 64-bit integer from little-endian format to the host’s native byte order.

### Data Types

[`CFSwappedFloat32`](/documentation/CoreFoundation/CFSwappedFloat32)

Structure holding a 32-bit float value in a platform-independentbyte order.

[`CFSwappedFloat64`](/documentation/CoreFoundation/CFSwappedFloat64)

Structure holding a 64-bit float value in a platform-independentbyte order.

### Constants

[`CFByteOrder`](/documentation/CoreFoundation/CFByteOrder)

Flags that identify byte order.

## See Also

  [Memory Management Programming Guide for Core Foundation](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/CFMemoryMgmt.html#//apple_ref/doc/uid/10000127i)



---

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)