DATA TYPE | SIZE (IN BYTES) | RANGE |
---|
short int | 2 | -32,768 to 32,767 |
unsigned short int | 2 | 0 to 65,535 |
unsigned int | 4 | 0 to 4,294,967,295 |
int | 4 | -2,147,483,648 to 2,147,483,647 |
long int | 4 | -2,147,483,648 to 2,147,483,647 |
unsigned long int | 4 | 0 to 4,294,967,295 |
long long int | 8 | -(2^63) to (2^63)-1 |
unsigned long long int | 8 | 0 to 18,446,744,073,709,551,615 |
signed char | 1 | -128 to 127 |
unsigned char | 1 | 0 to 255 |
float | 4 | -3.4*10(-38)~3.4*10(38) 有效位数(6-7) |
double | 8 | -1.7*10(-308)~1.7*10(308)有效位数(15-16) |
long double | 12 | -1.2*10(-4932)~1.2*10(4932) |
wchar_t | 2 or 4 | 1 wide character |
sizeof operator
Queries size of the object or type.
Used when actual size of the object must be known.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | /******************************************************************************
data type
*******************************************************************************/
#include<iostream>
using namespace std;
int main()
{
cout << "Size of char : " << sizeof(char)<< " byte" << endl;
cout << "Size of int : " << sizeof(int) << " bytes" << endl;
cout << "Size of float : " << sizeof(float)<< " bytes" <<endl;
cout << "Size of double : " << sizeof(double)<< " bytes" << endl;
int a=2147483645;
cout<<a<<endl;
cout<<a+2<<endl;
cout<<a+4<<endl;
return 0;
}
|