Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A bit on endianness

Endianness refers to the ordering of bytes in memory that make up a larger chunk of memory.  There's plenty of information on there on wikipedia for example, but here's a quick overview.  Systems are usually either big-endian or little-endian.  Stealing a table from wikipedia:

...

The systems we are working on are all little endian though, so the number 4097 would be stored as 0x01:0x10 in memory if we saved it as a short.  Saving it as an int would add some 0s for padding in there lie so: 0x01:0x10:0x00:0x00.  

...

Serializing our data

Now say we want to send a uint16 (unsigned short) through acomms along with a bunch of other data.  Well probably be constructing a long array or bytes and copying our data into it for transmission, then picking it back out at the other end.  Sticking with our simple uint16, let's look at how we can reconstruct the number given an array of bytes.  

...