1 字节!= 8 位的系统?

System where 1 byte != 8 bit?(1 字节!= 8 位的系统?)

本文介绍了1 字节!= 8 位的系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在读这样的句子

不要依赖 1 个字节的大小为 8 位

don't rely on 1 byte being 8 bit in size

使用 CHAR_BIT 而不是 8 作为常量在位和字节之间转换

use CHAR_BIT instead of 8 as a constant to convert between bits and bytes

等等.今天有哪些现实生活系统,这适用于哪些地方?(我不确定 C 和 C++ 在这方面是否存在差异,或者它是否实际上与语言无关.如有必要,请重新标记.)

et cetera. What real life systems are there today, where this holds true? (I'm not sure if there are differences between C and C++ regarding this, or if it's actually language agnostic. Please retag if neccessary.)

推荐答案

在较旧的机器上,小于 8 位的代码相当普遍,但其中大部分已经消失多年了.

On older machines, codes smaller than 8 bits were fairly common, but most of those have been dead and gone for years now.

C 和 C++ 已经规定 char最少为 8 位,至少可以追溯到 C89 标准..他们将char"和byte"视为本质上是同义词

C and C++ have mandated a minimum of 8 bits for char, at least as far back as the C89 standard. . They treat "char" and "byte" as essentially synonymous

然而,当前的机器(主要是 DSP)的最小类型大于 8 位——至少 12、14 甚至 16 位是相当常见的.Windows CE 的做法大致相同:它的最小类型(至少对于 Microsoft 的编译器)是 16 位.然而,他们char 视为 16 位 - 相反,他们采用(不符合)的方法,简单地不支持名为 char<的类型/code> .

There are, however, current machines (mostly DSPs) where the smallest type is larger than 8 bits -- a minimum of 12, 14, or even 16 bits is fairly common. Windows CE does roughly the same: its smallest type (at least with Microsoft's compiler) is 16 bits. They do not, however, treat a char as 16 bits -- instead they take the (non-conforming) approach of simply not supporting a type named char at all.

这篇关于1 字节!= 8 位的系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:1 字节!= 8 位的系统?

基础教程推荐