Sunday 27 April 2014

Data Types in C++




While doing programming in any computer programming language, we need to use various variables in order to store various data. Variables are nothing butspecially reserved memory locations which stores differentvalues. It means that when we create a variable we actually reserve some space in memory.

We may even like to store information of various data types like character, Boolean, wide character, floating point, integer, double floating point etc. It is based on the data type of a specific variable, the operating system allocates specified memory and decides on what can be stored in that reserved memory.

Here is the list of data types used in C++ language programming along with their range and Bit Width

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


No comments:

Post a Comment