[问题] 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