设为首页 加入收藏

TOP

2.1.1 Integral Types (2)
2013-10-07 15:25:39 来源: 作者: 【 】 浏览:61
Tags:2.1.1 Integral Types

Most computers associate a number—called an address—with each byte in memory. Given a machine that has 8-bit bytes and 32-bit words, we might represent a word of memory as follows:

 

In this illustration, each byte’s address is shown on the left, with the 8 bits of the byte following the address.

We can use an address to refer to any of several variously sized collections of bits starting at that address. It is possible to speak of the word at address 736424 or the byte at address 736426. We can say, for example, that the byte at address 736425 is not equal to the byte at address 736427.

To give meaning to the byte at address 736425, we must know the type of the value stored there. Once we knowthe type, we knowhowmany bits are needed to represent a value of that type and how to interpret those bits.

If we know that the byte at location 736425 has type “unsigned 8-bit integer,” then we know that the byte represents the number 112. On the other hand, if that byte is a character in the ISO-Latin-1 character set, then it represents the lower-case letter q. The bits are the same in both cases, but by ascribing different types to them, we interpret them differently.

C++(www.cppentry.com) 的内存模型相当简单,内存由一个个相邻的字节组成,每个字节有一个地址(整数),即“按字节寻址”;每个字节的含义由使用它的代码决定;字节的大小理论上由实现决定,而实际上通用处理器都是8-bit。

machineword, and longs in either one or twomachine words (on 32-bitmachines, ints and longs are usually the same size).

机器字(machine word)的大小由机器字长决定。通常我们用的都是32 位机,服务端编程(www.cppentry.com)普遍使用64 位机。

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇2.1.1 Integral Types (3) 下一篇2.1.1 Integral Types (1)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Java后端面试实习自 (2025-12-25 09:24:21)
·Java LTS版本有哪些 (2025-12-25 09:24:18)
·2025年,JAVA还值得 (2025-12-25 09:24:16)
·用 C 语言或者限制使 (2025-12-25 08:50:05)
·C++构造shared_ptr为 (2025-12-25 08:50:01)