In: Computer Science
Using a diagram/table, please illustrate how the personal record “John Cool, 45, 1980” will be stored in big- and little-endian byte ordering. The personal record includes a name (string), age (integer), and year (integer). The length of a byte is 8, and the length of a word is 32 for the computer.
John Cool, 45, 1980
Name: John Cool
Age: 45
Year: 1980
Big-endian ( 2 characters 1 byte 8 characters 1 word
4a | 6f | 68 | 6e | 20 | 43 | 6f | 6f | 6c | 00 | 00 | 00 |
1 word 2nd word 3rd word
39 | 35 | 00 | 00 |
padding
---------------------------------- 1 word -------------------------------------
31 | 89 | 38 | 30 |
------------------------------------------- 1 word --------------------------------- no padding needed
The padding goes to last and structure form
Name | padding |
Age | padding |
year |
For little endain :
1 byte 1 byte
word :1 | w | w | w | 4a | 6f | 68 | 6e | 20 | 43 | 6f | 6f | 6c |
word : 2 | 00 | 00 | 34 | 35 | unused | |||||||
word : 3 | unused due to bit shifting | 31 | 39 | 38 | 30 |
------ 1 byte --------
I have tried to explain it in very simple language and I hope that i have answered your question satisfactorily.Leave doubts in comment section if any.