[C ++] C ++ data types

Objects are data processing computer, and the data are present in a particular form (e.g. in the form of integer, floating point, character, etc.). Data structure refers to the organization of data. For example, a data structure is an array.

1.C ++ data types can be used are as follows:

2.C ++ data includes variable and constant, both having constant and variable type.

3.C ++ and the absence of uniform accuracy of various types of data, scale and proportion of the number of bytes in memory, various C ++ compiler system to make arrangements according to their own situation. Only a predetermined number of bytes occupied by data type int is not larger than long type, not less than short type. 16-bit C ++ generally machine systems, short integer (short) and integer (int) only two bytes long integer (long) 4 bytes. In Visual C ++ 6.0, the short integer is two bytes, integer and long integer 4 bytes.

4.Visual C ++ and the numeric character data as follows:

Types of Type identifier Byte count Value range
Integer  [signed] int 4  -2147483648 ~ +2147483647
Unsigned int  unsigned [int]   0 ~ 4,294,967,295
Short integer  short [int]  -32768 ~+ 32767
Unsigned short unsigned short [int]  0 ~ 65535
Long integer long [int]  -2147483648 ~ +2147483647 
Unsigned long integer unsigned long [int]   0 ~ 4294967295
Character [signed] char   -128 ~ +127
Unsigned char  unsigned char 0 ~ 255 
Single-precision float  3.4e38 ~ 3.4e38
Double double  1.7e308 ~ 1.7e308 
Long double long double  1.7e308 ~ 1.7e308 

Description:

Storage (1) integer data is stored in binary form, for example, 85 decimal integer in binary form is 1010101, is stored in memory in the form as shown below. (4 bytes Integer Data)

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1

(2) 如果指定signed,则数值以补码形式存放,存储单元的最高位(bit)用来表示数值的符号,如果指定为unsigned,则数值没有符号,全部二进制位都用来表示数值本身。正整数的原码、反码和补码相同,负整数的原码、反码、补码形式不同,负数的反码:符号位不动,其余各位对原码取反,它的补码是反码+1。

(3) 浮点型又称实型,分为float、double、long double三种,在Visual C++ 6.0中,对float提供6位有效数字,对double提供15位有效数字,并且float和double的数值方位不同。

 

参考文献

[1]谭浩强.C++程序设计[M].北京:清华大学出版社.

Guess you like

Origin www.cnblogs.com/chen-hw/p/11613939.html