Tuesday 15 April 2014

c - Little-endian and Big-endian -



c - Little-endian and Big-endian -

i must write routine conversion between 2 representations. i'm bit confused. if have architecture memory words of 32 bits , must store word 0xa15d23b1 big-endian memory become a1 after 5d after 23 , in end b1 little-endian rather memory b1 after 23 after 5d , after a1 right?

if can address individual bytes on machine , address of word 0 byte 1? in big-endian 5d? , in little-endian 5d too?

thanks reply me

big-endian memory layout important bytes first, whereas little-endian layout to the lowest degree important bytes first. given value 0xa15d23b1:

class="lang-none prettyprint-override">memory address 0 1 2 3 big-endian a1 5d 23 b1 little-endian b1 23 5d a1

note big-endian memory layout not alter respect word size, little-endian does. if consider 2 short words (16 bit), 0xa15d , 0x23b1 stored contiguously:

class="lang-none prettyprint-override">memory address 0 1 2 3 big-endian a1 5d 23 b1 little-endian 5d a1 b1 23

c

No comments:

Post a Comment