Wiki Page Content

Differences between revisions 21 and 22
Revision 21 as of 2017-02-16 23:52:17
Size: 2080
Editor: DanielG
Comment: (hopefully) improved formatting a bit
Revision 22 as of 2017-02-19 20:43:49
Size: 2078
Comment: Fixed typos.
Deletions are marked like this. Additions are marked like this.
Line 17: Line 17:
Endianness comes in two forms - big and little.   Endianness comes in two forms - big and little.
Line 19: Line 19:
 * SDL_BIG_ENDIAN means byte order is 4321, where the most significant byte is stored last  * SDL_BIG_ENDIAN means byte order is 4321, where the most significant byte is stored first
Line 32: Line 32:
For further information ab out Endianness read the [[https://en.wikipedia.org/wiki/Endianness|Wikipedia]] article on the subject. For further information about endianness read the [[https://en.wikipedia.org/wiki/Endianness|Wikipedia]] article on the subject.

Byte Order and Byte Swapping

Include File(s): SDL_endian.h

Introduction

This category contains functions for handling endian-specific values.

Simple data types like integers and floats consist of several bytes. A 32bit integer (Sint32), for example, uses four bytes (as each byte has 8 bits). Endianness describes how the system orders the bytes of this value in memory.

Endianness comes in two forms - big and little.

  • SDL_LIL_ENDIAN means byte order is 1234, where the least significant byte is stored first
  • SDL_BIG_ENDIAN means byte order is 4321, where the most significant byte is stored first

Example: Imagine the 32bit integer number 16,909,060 in decimal.

  • In hexadecimal that would be 0x01020304.
    0x01 is the most significant byte (the one that increases the value the most. 0x04 is the least significant byte (as it increases the value the least).
    When that is stored in memory on a little-endian system they are stored with the least significant byte first, producing the byte stream:

    • 0x04 0x03 0x02 0x01

    When that is stored in memory on a big-endian system they are stored with the most significant byte first, producing the byte stream:
    • 0x01 0x02 0x03 0x04

For further information about endianness read the Wikipedia article on the subject.

SDL_BYTEORDER is a macro that corresponds to the byte order used by the processor type it was compiled for.

  • SDL_BYTEORDER is SDL_LIL_ENDIAN for x86, x64, and similar systems that use the little endian byte order.
  • SDL_BYTEORDER is SDL_BIG_ENDIAN for PowerPC and similar systems that use the big endian byte order.

Functions


CategoryCategory

None: CategoryEndian (last edited 2017-02-19 20:43:49 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit