Number: 0x0a0b0c0d. Here LSB is 0x0d and MSB is 0x0a
Memory Address: 0x100 0x101 0x102 0x103
+--------+--------+--------+--------+
| | | | |
+--------+--------+--------+--------+
Little-Endian: In LE, LSB is in lowest memory and MSB in highest memory address. So, the number is stored as: 0x0d0c0b0a in memory. Number: 0x0a0b0c0d. Here LSB is 0x0d and MSB is 0x0a
Memory Address: 0x100 0x101 0x102 0x103
+--------+--------+--------+--------+
| 0x0d | 0x0c | 0x0b | 0x0a |
+--------+--------+--------+--------+
code:
int i = 0x0a0b0c0d;
char *c = (char *) &i;
printf ("0x%x\n", *c);
// Output is 0xd = little-endian.
Number: 0x0a0b0c0d.
Memory Address: 0x100 0x101 0x102 0x103
+--------+--------+--------+--------+
| 0x0a | 0x0b | 0x0c | 0x0d |
+--------+--------+--------+--------+
code:
int i = 0x0a0b0c0d;
char *c = (char *) &i;
printf ("0x%x\n", *c);
// Output is 0xa = big-endian.
Host-Byte Order: Ordering on the host machine. If processor is x86, its little-endian, if its Motorola's 68k, its big-endian.Labels: big-endian, endianness, host byte order., little-endian, network byte order