gpt4 book ai didi

C++ 字节依赖于实现

转载 作者:太空狗 更新时间:2023-10-29 23:25:28 25 4
gpt4 key购买 nike

我一直在阅读 C Primer Plus。

据说:请注意,字节的含义取决于实现。因此,一个 2 字节的 int 在一个系统上可能是 16 位,在另一个系统上可能是 32 位。

这里我觉得我不太确定。根据我的理解,1 个字节总是 = 8 位,所以 2-byte int = 2 * 8 = 16 位 是有道理的。但是从这个陈述来看,听起来有些系统定义了 1 字节 = 16 位。那是对的吗?一般来说,我应该如何理解这个声明?

最佳答案

C++ 标准第 1.7 节第 1 点证实了这一点:

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 implementation defined. (...) The memory available to a C++ program consists of one or more sequences of contiguous bytes. Every byte has a unique address.

关于C++ 字节依赖于实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25222916/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com