为什么位数总是(?)二的幂? [英] Why is number of bits always(?) a power of two?

查看:119
本文介绍了为什么位数总是(?)二的幂?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有8位,16位,32位和64位硬件体系结构和操作系统。但不是,比方说,42位或69位的。

We have 8-bit, 16-bit, 32-bit and 64-bit hardware architectures and operating systems. But not, say, 42-bit or 69-bit ones.

为什么呢?它是一个根本的转变,使得2 ^ n位一个更好的选择,或者只是与现有系统的兼容性? (这显然方便的一个64位的寄存器可以存放两个32位的指针,或者一个32位的数据单元可容纳4个字节)。

Why? Is it something fundamental that makes 2^n bits a better choice, or is just about compatibility with existing systems? (It's obviously convenient that a 64-bit register can hold two 32-bit pointers, or that a 32-bit data unit can hold 4 bytes.)

推荐答案

这是传统的主要问题。它甚至不是总是如此。例如,在处理器浮点单元(甚至当代的)具有80位的寄存器。并没有什么,这将迫使我们有​​8位字节而不是13位字节。

That's mostly a matter of tradition. It is not even always true. For example, floating-point units in processors (even contemporary ones) have 80-bits registers. And there's nothing that would force us to have 8-bit bytes instead of 13-bit bytes.

有时,这种具有数学推理。例如,如果你决定有N位字节和想要做的整数乘法正是你需要2N位来存储结果。然后,你也想加/减/乘那些2N位整数,现在你需要2N位通用寄存器用于存储加法/减法的结果和4N-位寄存器,用来存储乘法结果。

Sometimes this has mathematical reasoning. For example, if you decide to have an N bits byte and want to do integer multiplication you need exactly 2N bits to store the results. Then you also want to add/subtract/multiply those 2N-bits integers and now you need 2N-bits general-purpose registers for storing the addition/subtraction results and 4N-bits registers for storing the multiplication results.

这篇关于为什么位数总是(?)二的幂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆