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位的系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

C++ find method not working(C++查找方法不起作用)
How to determine the offset of an element of a tuple at compile time?(如何在编译时确定元组元素的偏移量?)
Error: control Reaches end of non void function(错误:控件已到达非无效函数的末尾)
Error: Jump to case label in switch statement(错误:跳转到SWITCH语句中的CASE标签)
Order of elements in set of pointers(指针集中元素的顺序)
error while loading shared libraries: jvm.dll(加载共享库时出错:jvm.dll)