Big endian/little endian

From GHER

Jump to: navigation, search

Some people write from "left-to-right" and others "right-to-left". The same is true for CPUs. This is particularly a problem when data is saved to the disk and exchanged with other computers.

There two ways:

  • big endian (native on ARM, PPC, MISP, ... processors)
  • little endian (native on Intel and AMD processors)

On Intel and AMD processors, compilers (such as gfortran, ifort and pgf90) can the emulate big endian format while reading and writing data to files. However compilers for big-endian processors generally cannot emulate little endian (has this changed?).

Contents

Compiler options

gfortran

big-endian
-fconvert=big-endian
little-endian
-fconvert=little-endian

ifort

big-endian
-convert big_endian
little-endian
-convert little_endian

pgf90

Use the option -byteswapio for using the other format than the native format.


Which format should I use

Advantage Disadvantage
Always native the fastest difficult to exchange data files
big-endian compatible with all platforms (if byte conversion is used on little-endian CPUs) slight performance penalty on little-endian CPUs
little-endian no performance penalty with the currently most common CPUs architecture (Intel, AMD) difficult to exchange data files with big-endian CPUs
Personal tools