为什么二进制用八进制表示?
我一直在谷歌上寻找答案,但似乎找不到。但二进制是以字节/八位字节、8 位表示的。所以字符 a (我认为)是 01100010,
而单词 hey 是
01101000
01100101
01111001
所以我的问题是,为什么是 8?这个数字适合计算机使用吗?我注意到 32 位/62 位计算机都是 8 的倍数……那么这是否与第一台计算机的制造方式有关?
抱歉,如果这个问题不符合 Q/A 标准...它与代码无关,但我想不出其他地方可以问它。
I've been looking for the answer on google and can't seem to find it. But binary is represented in bytes/octets, 8 bits. So the character a (I think) is 01100010,
and the word hey is
01101000
01100101
01111001
So my question is, why 8? Is this just a good number for the computer to work with? And I've noticed how 32 bit/ 62 bit computers are all multiples of eight... so does this all have to do with how the first computers were made?
Sorry if this question doesn't meet the Q/A standards... its not code related but I can't think of anywhere else to ask it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
答案确实是“历史原因”。
计算机内存必须在某种程度上可寻址。当您向 RAM 请求信息时,您需要指定您想要哪些信息 - 它会将这些信息返回给您。理论上,可以产生位寻址存储器:你请求一位,你就得到一位。
但这不会很有效,因为将处理器连接到内存的接口需要能够传达足够的信息来指定它想要的地址。访问粒度越小,在给出足够准确的检索地址之前,您需要的线路就越多(或者沿着相同数量的线路推送更多的线路)。此外,多次返回一位的效率低于一次返回多个位的效率(旁注:一般情况下是这样。这是串行与并行的争论,并且由于系统复杂性和物理性能降低,串行接口通常可以运行得更快。但总体而言,一次更多位的效率更高)。
其次,系统中的内存总量部分受到最小可寻址块的大小的限制,因为除非使用可变大小的内存地址,否则只有有限数量的地址可以工作与 - 但每个地址代表您可以选择的位数。因此,具有逻辑字节可寻址存储器的系统可以容纳的 RAM 是具有逻辑位可寻址存储器的系统的八倍。
因此,我们使用逻辑上可寻址的不太精细级别的内存(尽管物理上没有 RAM 芯片只会返回一个字节)。只有二的幂才真正有意义,并且历史上访问级别一直是字节。它可以很容易地是一个半字节或一个两字节字,事实上,较旧的系统确实具有比八位更小的块。
当然,现在现代处理器大多以缓存行大小的增量消耗内存,但我们表达分组和划分当前虚拟地址空间的方法仍然存在,并且 CPU 指令占用的最小内存量 可以直接访问的仍然是八位块。 CPU 指令的机器代码(和/或进入处理器的路径)必须以与连接到内存控制器的电线数量相同的方式增长,以便寄存器可寻址 - 这与以下问题相同我之前谈到的系统内存可访问性。
The answer is really "historical reasons".
Computer memory must be addressable at some level. When you ask your RAM for information, you need to specify which information you want - and it will return that to you. In theory, one could produce bit-addressable memory: you ask for one bit, you get one bit back.
But that wouldn't be very efficient, since the interface connecting the processor to the memory needs to be able to convey enough information to specify which address it wants. The smaller the granularity of access, the more wires you need (or the more pushes along the same number of wires) before you've given an accurate enough address for retrieval. Also, returning one bit multiple times is less efficient than returning multiple bits one time (side note: true in general. This is a serial-vs-parallel debate, and due to reduced system complexity and physics, serial interfaces can generally run faster. But overall, more bits at once is more efficient).
Secondly, the total amount of memory in the system is limited in part by the size of the smallest addressable block, since unless you used variably-sized memory addresses, you only have a finite number of addresses to work with - but each address represents a number of bits which you get to choose. So a system with logically byte-addressable memory can hold eight times the RAM of one with logically bit-addressable memory.
So, we use memory logically addressable at less fine levels (although physically no RAM chip will return just one byte). Only powers of two really make sense for this, and historically the level of access has been a byte. It could just as easily be a nibble or a two-byte word, and in fact older systems did have smaller chunks than eight bits.
Now, of course, modern processors mostly eat memory in cache-line-sized increments, but our means of expressing groupings and dividing the now-virtual address space remained, and the smallest amount of memory which a CPU instruction can access directly is still an eight-bit chunk. The machine code for the CPU instructions (and/or the paths going into the processor) would have to grow the same way the number of wires connecting to the memory controller would in order for the registers to be addressable - it's the same problem as with the system memory accessibility I was talking about earlier.
“在 20 世纪 60 年代初期,AT&T 首先在长途干线上引入了数字电话。这些电话使用了 8 位 µ-law 编码。这项巨额投资有望降低 8 位数据的传输成本。使用 8-数字电话的比特代码也导致 8 位数据八位字节被采用作为早期互联网的基本数据单元”
http://en.wikipedia.org/wiki/Byte
不确定这是否属实。不过,这似乎只是 IEEE 采用的符号和风格。
"In the early 1960s, AT&T introduced digital telephony first on long-distance trunk lines. These used the 8-bit µ-law encoding. This large investment promised to reduce transmission costs for 8-bit data. The use of 8-bit codes for digital telephony also caused 8-bit data octets to be adopted as the basic data unit of the early Internet"
http://en.wikipedia.org/wiki/Byte
Not sure how true that is. It seems that that's just the symbol and style adopted by the IEEE, though.
我们使用 8 位字节的原因之一是因为我们周围世界的复杂性具有明确的结构。在人类的尺度上,观察到的物理世界具有有限数量的独特状态和模式。我们先天对信息进行分类、区分秩序和混乱的能力有限,大脑的记忆量有限——这些都是我们选择 [2^8...2^64] 状态足以满足我们日常基本需求的原因计算需求。
One reason why we use 8-bit bytes is because the complexity of the world around us has a definitive structure. On the scale of human beings, observed physical world has finite number of distinctive states and patterns. Our innate restricted abilities to classify information, to distinguish order from chaos, finite amount of memory in our brains - these all are the reasons why we choose [2^8...2^64] states to be enough to satisfy our everyday basic computational needs.