The SWAP_ENDIAN function reverses the byte ordering of arbitrary scalars, arrays or structures. It can make “big endian” number “little endian” and vice-versa.
Note: The BYTEORDER procedure can be used to reverse the byte ordering of scalars and arrays (SWAP_ENDIAN also allows structures).
This routine is written in the IDL language. Its source code can be found in the file swap_endian.pro in the lib subdirectory of the IDL distribution.
Examples
A = SWAP_ENDIAN(A)
Syntax
Result = SWAP_ENDIAN(Variable [, /SWAP_IF_BIG_ENDIAN] [, /SWAP_IF_LITTLE_ENDIAN])
Return Value
SWAP_ENDIAN returns values of the same type and structure as the input value, with the pertinent bytes reversed.
Arguments
Variable
The named variable—scalar, array, or structure—to be swapped.
Keywords
SWAP_IF_BIG_ENDIAN
If this keyword is set, the swap request will only be performed if the platform running IDL uses “big endian” byte ordering. On little endian machines, the SWAP_ENDIAN request quietly returns without doing anything. Note that this keyword does not refer to the byte ordering of the input data, but to the computer hardware.
SWAP_IF_LITTLE_ENDIAN
If this keyword is set, the swap request will only be performed if the platform running IDL uses “little endian” byte ordering. On big endian machines, the SWAP_ENDIAN request quietly returns without doing anything. Note that this keyword does not refer to the byte ordering of the input data, but to the computer hardware.
Version History
Pre-4.0 |
Introduced |
5.6 |
Added SWAP_IF_BIG_ENDIAN and SWAP_IF_LITTLE_ENDIAN keywords
|
See Also
BYTEORDER, SWAP_ENDIAN_INPLACE