What Is Endianness?

The endianness indicates the format in which bytes are stored in a computer. There are two types of endianness, Big and Little endian endian. Big endian is the number as it normally (in English or Spanish language) is written, this is 20 and 2 is equivalent to 22 Little endian instead on the numbers backwards (is similar to read numbers in German) is written, ie 2 and 20 which equals 22.

ess the number 1234;

  •     In Big endian is written 1234
  •     In Little endian is written 3412

This is important in the world of databases since many databases working on different hardwares. In Oracle exists the V$TRANSPORTABLE_PLATFORM view (see query below), which indicates the type of platform and endianness, in this case it is used for the Transportable Tablespace feature, if we go from a source to a destination are the same (from Big to Big, or from Little to Little) tablespace can directly copy (scp, ftp …), however if we are to different platforms endianness (from Big to Little, or from Littel to Big ) must perform a conversion process, which is done with RMAN.



 ___________ _________________________________ ______________
           1 Solaris[tm] OE (32-bit)           Big
           2 Solaris[tm] OE (64-bit)           Big
           7 Microsoft Windows IA (32-bit)     Little
          10 Linux IA (32-bit)                 Little
           6 AIX-Based Systems (64-bit)        Big
           3 HP-UX (64-bit)                    Big
           5 HP Tru64 UNIX                     Little
           4 HP-UX IA (64-bit)                 Big
          11 Linux IA (64-bit)                 Little
          15 HP Open VMS                       Little
           8 Microsoft Windows IA (64-bit)     Little
           9 IBM zSeries Based Linux           Big
          13 Linux 64-bit for AMD              Little
          16 Apple Mac OS                      Big
          12 Microsoft Windows 64-bit for AMD  Little
          17 Solaris Operating System (x86)    Little
          18 IBM Power Based Linux             Big


If we create a file called “one.txt” with the following string 1234, and see its contents in hexadecimal format, using the od command we have;

  • On Solaris (64-bit) (Big) : 030462 031464 005000
  • On HP Tru64 (Little) : 031061 032063 000012


Actually the process of converting values from Little to Big or from Big to Little is very easy, see this example in C;

/*** Compiled with CC for Solaris ***/

#include <stdio.h>

int main(int argc, char *argv[])
unsigned long x = 1234;
unsigned long aux = 0;
unsigned long res;

  aux += (x & 0x000000FF)<<24;
  aux += (x & 0xFF000000)>>24;
  aux += (x & 0x0000FF00)<<8;
  aux += (x & 0x00FF0000)>>8;

printf("%#010x\n", aux);






Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s