Byte Ordering

Utilities for swapping the order of bytes to match the Endianness of the required platform. More...

+ Collaboration diagram for Byte Ordering:

Macros

#define BYTEORDER_SWAPW16(x)
 Switch the byte ordering of a short integer. More...
 
#define BYTEORDER_SWAPW32(x)
 Switch the byte ordering of an integer. More...
 
#define BYTEORDER_SWAPW64(x)
 Switch the byte ordering of an integer. More...
 
#define BYTEORDER_SWAPF32
 Switch the byte ordering of a float. More...
 
#define BYTEORDER_SWAPF64
 Switch the byte ordering of a double. More...
 

Detailed Description

Utilities for swapping the order of bytes to match the Endianness of the required platform.

An introduction to the issue of endianness can be found at http://en.wikipedia.org/wiki/Endianness.

Of particular relevance is that a Macintosh with a PPC processor uses a Big-endian byte ordering, whereas an Intel processor in a Mac or Windows machine will use a Little-endian byte ordering.

These utilities are defined to assist with cases where byte ordering needs to be manipulated for floats or ints. Note that floats are subject to the same byte ordering rules as integers. While the IEEE defines the bits, the machine still defines how the bits are arranged with regard to bytes.

Macro Definition Documentation

#define BYTEORDER_SWAPF32

Switch the byte ordering of a float.

Parameters
xA float.
Returns
A float with the byte-ordering swapped.
#define BYTEORDER_SWAPF64

Switch the byte ordering of a double.

Parameters
xA double.
Returns
A double.
#define BYTEORDER_SWAPW16 (   x)

Switch the byte ordering of a short integer.

Parameters
xA short integer.
Returns
A short integer with the byte-ordering swapped.
#define BYTEORDER_SWAPW32 (   x)

Switch the byte ordering of an integer.

Parameters
xAn integer.
Returns
An integer with the byte-ordering swapped.
#define BYTEORDER_SWAPW64 (   x)

Switch the byte ordering of an integer.

Parameters
xAn integer.
Returns
An integer with the byte-ordering swapped.
  Copyright © 2015, Cycling '74