码迷,mamicode.com
首页 > 编程语言 > 详细

C++ Data Types

时间:2016-08-21 12:24:46      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:

Primitive Built-in Types:

C++ offer the programmer a rich assortment of built-in as well as user defined data types. Following table lists down seven basic C++ data types:

 

Type Keyword
Boolean bool
Character char
Integer int
Floating point float
Double floating point double
Valueless void
Wide character wchar_t

The following table shows the variable type, how much memory it takes to store the value in memory, and what is maximum and minimum value which can be stored in such type of variables.

 

Type Typical Bit WidthTypical Range
char 1byte -128 to 127 or 0 to 255
unsigned char 1byte 0 to 255
signed char 1byte -128 to 127
int 4bytes -2147483648 to 2147483647
unsigned int 4bytes 0 to 4294967295
signed int 4bytes -2147483648 to 2147483647
short int 2bytes -32768 to 32767
unsigned short int 2bytes 0 to 65,535
signed short int 2bytes -32768 to 32767
long int 4bytes -2,147,483,648 to 2,147,483,647
signed long int 4bytes -2,147,483,648 to 2,147,483,647
unsigned long int 4bytes 0 to 4,294,967,295
float 4bytes +/- 3.4e +/- 38 (~7 digits)
double 8bytes +/- 1.7e +/- 308 (~15 digits)
long double 8bytes +/- 1.7e +/- 308 (~15 digits)
wchar_t 2 or 4 bytes 1 wide character

The sizes of variables might be different from those shown in the above table, depending on the compiler and the computer you are using.

数据来源:http://www.tutorialspoint.com/cplusplus/cpp_data_types.htm

32位与64位操作系统下各类型长度对比:http://blog.csdn.net/sky_qing/article/details/11650497

C++ Data Types

标签:

原文地址:http://www.cnblogs.com/zhongzhiqiang/p/5792291.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!