XML

kent logo

CO527 Anonymous Questions and Answers Keyword Index

This page provides a keyword index to questions and answers. Clicking on a keyword will take you to a page containing all questions and answers for that keyword, grouped by year.

To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.

Keyword reference for endianism

2010

Question 7 (2010):

Submission reference: IN1998

Can you explain what big-endian and little-endian organisation is again, having looked over the slides and the diagram I cannot make any sense of what they mean. Thanks.

Answer 7:

It's the way that words (16 or 32 bits or larger) values are stored in memory, which is essentially accessed in 8-bit quantities. In the slides, a 32-bit value (let's say 0x1234abcd) is shown stored in little-endian and big-endian order. In little-endian, the least-significant-byte goes first, so at addr you would find 0xcd, at addr+1 0xab, at addr+2 0x34, and at addr+3 0x12. Big-endian is the other way around, i.e. the most-significant-byte goes first. Little-endian is probably more intuitive (and more common for CISC machines). Which byte-ordering is used can affect programs if programmers are not careful, particularly in C. You can write a simple test program, e.g.:

#include 
int main (void)
{
  int val = 0x1234abcd;
  char *vp = (char *)&val;

  if (*vp == 0x12) {
    printf ("Big endian!\n");
  } else if (*vp == 0xcd) {
    printf ("Little endian!\n");
  } else {
    printf ("Something else..?\n");
  }
}

Keywords: endianism

Valid CSS!

Valid XHTML 1.0!

Maintained by Fred Barnes, last modified Sun May 17 14:57:41 2015