在计算机内存和C ++方面定义“字节”有什么区别? [英] what is the difference in defining the 'byte' in terms of computer memory and in terms of C++?

查看:177
本文介绍了在计算机内存和C ++方面定义“字节”有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是参考由Stephen Prata提供的C ++ Primer Plus文本 -

This is with reference to the text from C++ Primer Plus by Stephen Prata-

字节表示测量单位意义上的8位内存单位描述计算机中的内存量。
然而,C ++定义了不同的字节。 C ++字节由至少足够的相邻位组成,以适应实现的基本字符集。

A byte means a 8-bit unit of memory in the sense of unit of measurement that describes the amount of memory in a computer. However, C++ defines byte differently. The C++ byte consists of at least enough adjacent bits to accommodate the basic character set for the implementation.

你可以解释一个C ++编译器是否有16位字节,而系统有8位字节,那么程序如何在这样的系统上运行?

Can you please explain if a C++ compiler have 16-bit byte whereas the system has 8-bit byte then how will the program run on such system?

推荐答案

的字节是引用自维基百科


主要商业计算架构的普及帮助了8位大小的普遍接受。

The popularity of major commercial computing architectures has aided in the ubiquitous acceptance of the 8-bit size.

另一方面,C ++中的内存单元由内置类型 char 提供;在一些实现下, char 可以是8位内存块;但在您的C ++程序中,每个 sizeof(T) 将以 sizeof(char)的倍数表示,等于 1

On the other hand, the unit of memory in C++ is given by the built-in type char; under some implementation, a char may not be an 8-bit memory chunk; though, in your C++ program every sizeof(T) will be expressed in multiples of sizeof(char), that is equal to 1 by definition.

特定实现的字节中的位数记录到宏 CHAR_BIT 标准标题 < climits> 。保证 char 至少为8位。

The number of bit in a byte for a particular implementation is recorded into the macro CHAR_BIT, defined inside the standard header <climits>. It is guaranteed that char is at least 8-bits.

最后,这是


由基本的C ++标准(§1.7, intro.memory C ++内存模型中的存储单元是字节。一个字节至少足够大以包含
基本执行字符集(2.3)的任何成员和Unicode UTF-8
编码形式的8位代码单元,并且由连续序列的位,其数量是实现定义的。
最低有效位称为低位位;最高有效位称为高位
。 C ++程序可用的存储器由一个或多个连续字节序列组成。每个
字节都有一个唯一的地址。

The fundamental storage unit in the C++ memory model is the byte. A byte is at least large enough to contain any member of the basic execution character set (2.3) and the eight-bit code units of the Unicode UTF-8 encoding form and is composed of a contiguous sequence of bits, the number of which is implementationdefined. The least significant bit is called the low-order bit; the most significant bit is called the high-order bit. The memory available to a C++ program consists of one or more sequences of contiguous bytes. Every byte has a unique address.

这篇关于在计算机内存和C ++方面定义“字节”有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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