A) four-byte sequence 0xAB 0xAA 0x2A 0x96 stored in consecutive memory cells in
ID: 3858362 • Letter: A
Question
A) four-byte sequence 0xAB 0xAA 0x2A 0x96 stored in consecutive memory cells in a little-endian architecture represents ___________ (decimal) when interpreted as a 32-bit signed integer.
B) The four-byte sequence 0xC1 0xAC 0xDC 0x4B stored in consecutive memory cells in a little-endian architecture represents ___________ (decimal) when interpreted as a 32-bit signed integer.
C) The four-byte sequence 0x8D 0xAB 0x52 0xAB stored in consecutive memory cells in a little-endian architecture represents ___________ (decimal) when interpreted as a 32-bit unsigned integer.
Explanation / Answer
In little-endian we will store the least significant byte in the smallest address.
which implies of all bytes least significant byte is the 1st accessible byte.
A)
If we store 0xAB 0xAA 0x2A 0x96 in consecutive memory cells in little-endian format
then 0xAB is the 1st byte to access [ LSB byte ]
0xAA is the 2nd byte to access
0x2A is the 3rd byte to access
0x96 is the last byte to access [ MSB byte ]
We know that any word will start with MSB byte and end with LSB byte
Hence the overall word will be 0x96 0x2A 0xAA 0xAB [ MSB to LSB ].
In binary format it will be 10010110 00101010 10101010 10101011
Given this is 32-bit signed integer hence the 1st bit will indicate sign
and it is 1 which indicates the number is negative.
After converting the number to decimal the value is -1775588693.
B)
If we store 0xC1 0xAC 0xDC 0x4B in consecutive memory cells in little-endian format
then 0xC1 is the 1st byte to access [ LSB byte ]
0xAC is the 2nd byte to access
0xDC is the 3rd byte to access
0x4B is the last byte to access [ MSB byte ]
We know that any word will start with MSB byte and end with LSB byte
Hence the overall word will be 0x4B 0xDC 0xAC 0xC1 [ MSB to LSB ].
In binary format it will be 01001011 11011100 10101100 11000001
Given this is 32-bit signed integer hence the 1st bit will indicate sign
and it is 0 which indicates the number is positive.
After converting the number to decimal the value is 1272753345.
C)
If we store 0x8D 0xAB 0x52 0xAB in consecutive memory cells in little-endian format
then 0x8D is the 1st byte to access [ LSB byte ]
0xAB is the 2nd byte to access
0x52 is the 3rd byte to access
0xAB is the last byte to access [ MSB byte ]
We know that any word will start with MSB byte and end with LSB byte
Hence the overall word will be 0xAB 0x52 0xAB 0x8D [ MSB to LSB ].
In binary format it will be 10101011 01010010 10101011 10001101
Given this is 32-bit unsigned integer hence the 1st bit will not indicate any sign
here and all the bits together gives us the value.
After converting the number to decimal the value is 2874321805.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.