Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1045272 of Endianness

  • Revision slug: Glossary/Endianness
  • Revision title: Endianness
  • Revision id: 1045272
  • Created:
  • Creator: klez
  • Is current revision? Yes
  • Comment restored lost formatting

Revision Content

"Endian" and "endianness" (or "byte-order") describe how computers organize the bytes that make up numbers.

Each memory storage location has an index or address. Every byte can store an 8-bit number (i.e. between 0x00 and 0xff), so you must reserve more than one byte to store a larger number. By far the most common ordering of multiple bytes in one number is the little-endian, which is used on all Intel processors. Little-endian means storing bytes in order of least-to-most-significant (where the least significant byte takes the first or lowest address), comparable to a common European way of writing dates (e.g., 31 December 2050).

Naturally, big-endian is the opposite order, comparable to an ISO date (2050-12-31). Big-endian is also often called "network byte order", because Internet standards usually require data to be stored big-endian, starting at the standard UNIX socket level and going all the way up to standardized Web binary data structures. Also, older Mac computers using 68000-series and PowerPC microprocessors formerly used big-endian.

Examples with the number 0x12345678 (i.e. 305 419 896 in decimal):

  • little-endian:  0x78 0x56 0x34 0x12
  • big-endian: 0x12 0x34 0x56 0x78
  • mixed-endian (historic and very rare): 0x34 0x12 0x78 0x56

See also

  • {{jsxref("ArrayBuffer")}}
  • {{jsxref("DataView")}}
  • Typed Arrays
  • {{Interwiki("wikipedia", "Endianness")}} on Wikipedia

Revision Source

<p id="Summary">"Endian" and "endianness" (or "byte-order") describe how computers organize the bytes that make up numbers.</p>

<p>Each memory storage location has an index or&nbsp;address. Every&nbsp;byte can store an 8-bit number (i.e. between <code>0x00</code>&nbsp;and&nbsp;<code>0xff</code>), so you must reserve more than one byte to store a larger number. By far the most common <em>ordering&nbsp;</em>of multiple bytes in one number is the&nbsp;<strong>little-endian,&nbsp;</strong>which is used on all Intel processors.<em>&nbsp;</em>Little-endian means storing&nbsp;bytes in order of least-to-most-significant (where the least significant byte takes the first or lowest address), comparable to&nbsp;a common European way of writing dates (e.g., 31 December 2050).</p>

<p>Naturally,&nbsp;<strong>big-endian&nbsp;</strong>is the opposite order, comparable to an ISO date (2050-12-31). Big-endian is also often called "network byte order", because Internet standards usually require data to be stored big-endian, starting at the standard UNIX socket level and going all the way up to standardized Web binary data structures. Also, older Mac computers using 68000-series and PowerPC microprocessors formerly used big-endian.</p>

<p>Examples with the number&nbsp;<code>0x12345678</code> (i.e. 305 419 896 in decimal):</p>

<ul>
 <li><em>little-endian:&nbsp;</em>&nbsp;<code style="font-style: normal;">0x78 0x56 0x34 0x12</code></li>
 <li><em>big-endian:&nbsp;</em><span style="font-family:consolas,monaco,andale mono,monospace">0x12 0x34 0x56 0x78</span></li>
 <li><em>mixed-endian</em>&nbsp;(historic and very rare):&nbsp;<span style="font-family:consolas,monaco,andale mono,monospace">0x34 0x12 0x78 0x56</span></li>
</ul>

<h2>See also</h2>

<ul>
 <li>{{jsxref("ArrayBuffer")}}</li>
 <li>{{jsxref("DataView")}}</li>
 <li><a href="/en-US/docs/Web/JavaScript/Typed_arrays">Typed Arrays</a></li>
 <li>{{Interwiki("wikipedia", "Endianness")}} on Wikipedia</li>
</ul>
Revert to this revision