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

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

问题描述

我们有 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.

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

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