[問題] big-endian vs little-endian

作者: zzss2003 (brotherD)   2018-04-18 21:02:15
網址: https://stackoverflow.com/questions/13926760/the-reason-behind-endianness
網址裡面有提到big跟little的優缺點,但小弟資質不良,無法完全理解,想請各位前輩開

little-endian:
1. The little-endian system has the property that the same value can be read
from memory at different lengths without using different addresses
請問,at different lengths without using different addresses是什麼意思?
2. When adding or subtracting multi-byte numbers, the least significant byte
must be fetched first to see if there is a carryover to more significant
bytes. Because the least-significant byte is read first in little-endian
numbers, the system can parallelize and begin calculation on this byte while
fetching the following byte(s).
這一段我看得懂,大致上的意思是little-endian有辦法一邊fetch lower byte 一邊做計
算,如果是big-endian就必須全部fetch下來才可以做計算
big-endian:
1. it is simple to tell whether a number is positive or negative by simply
examining the bit at offset 0 in the lowest order byte.
這邊我也看得懂,big-endian的優點就是很容易比出兩個數字的大小。
2. binary digits are ordered as most people order base-10 digits. This is
advantageous performance-wise when converting from binary to decimal.
不懂,為什麼從2進制轉換成10進制會有performance-wise?
我認為不管是big還是little,轉成10進制的效能都是一樣的,只是big從MSB開始加,
little從LSB開始加
請各位指點迷津,謝謝
作者: chuegou (chuegou)   2018-04-18 21:12:00
應該就是字面上的意思 一個是指標指到頭 一個指到尾
作者: bibo9901 (function(){})()   2018-04-18 22:42:00
1.的意思是同一個地址可以當int*和short*因為開頭對齊, 所以轉型很容易, 只有寬度不同而已而且little轉10進位並不是從LSB開始一路往回就好
作者: Lipraxde (Lipraxde)   2018-04-19 00:33:00
從高的開始轉,那萬一比它的有進位是不是就要回頭算?*比它低的

Links booklink

Contact Us: admin [ a t ] ucptt.com