看书

放假了,心也平静下来了,休息的这几天,每天都抱这2本书换着看,一本是刚刚出的C++ PRIMER 第四版,一本是汇编(上学的时候很用心的看过,那时候看完了也不知道在什么地方可以发挥)。
我在看C++这本书的时候,看到第二章节,讲到内置类型在内存中所占的空间(在内存中最小单位是字节大小)书上讲的让我感到一点点困惑,所以今天去英文网站上找了点资料。

Fundamental data types

When programming, we store the variables in our computer's memory, but the computer has to know what we want to store in them, since it is not going to occupy the same amount of memory to store a simple number than to store a single letter or a large number, and they are not going to be interpreted the same way.

The memory in our computers is organized in bytes. A byte is the minimum amount of memory that we can manage in C++. A byte can store a relatively small amount of data: one single character or a small integer (generally an integer between 0 and 255). In addition, the computer can manipulate more complex data types that come from grouping several bytes, such as long numbers or non-integer numbers.

Next you have a summary of the basic fundamental data types in C++, as well as the range of values that can be represented with each one:

NameDescriptionSize*Range*
charCharacter or small integer.1bytesigned: -128 to 127
unsigned: 0 to 255
short int
(short)
Short Integer.2bytessigned: -32768 to 32767
unsigned: 0 to 65535
intInteger.4bytessigned: -2147483648 to 2147483647
unsigned: 0 to 4294967295
long int
(long)
Long integer.4bytessigned: -2147483648 to 2147483647
unsigned: 0 to 4294967295
boolBoolean value. It can take one of two values: true or false.1bytetrue or false
floatFloating point number.4bytes3.4e +/- 38 (7 digits)
doubleDouble precision floating point number.8bytes1.7e +/- 308 (15 digits)
long doubleLong double precision floating point number.8bytes1.7e +/- 308 (15 digits)
wchar_tWide character.2bytes1 wide character

* The values of the columns Size and Range depend on the architecture of the system where the program is compiled and executed. The values shown above are those found on most 32bit systems. But for other systems, the general specification is that int has the natural size suggested by the system architecture (one word) and the four integer types char, short, int and long must each one be at least as large as the one preceding it. The same applies to the floating point types float, double and long double, where each one must provide at least as much precision as the preceding one.

注:(以后有时间会把以上这段话翻译过来)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值