C++ data types
When programming, we store the variables in our computer’s memory, but the computer has to know what kind of data 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:
Data types are as follows -
Name Description Size Range
char Character or small integer. 1byte signed: -128 to 127
unsigned: 0 to 255
Name Description Size Range
char Character or small integer. 1byte signed: -128 to 127
unsigned: 0 to 255
Short int Short Integer. 2bytes signed: -32768 to 32767
unsigned: 0 to 65535
int Integer 4bytes signed: -2147483648 to
2147483647
unsigned: 0 to 4294967295
unsigned: 0 to 65535
int Integer 4bytes signed: -2147483648 to
2147483647
unsigned: 0 to 4294967295
Long int (long) Long integer. 4bytes signed: -2147483648 to
2147483647
unsigned: 0 to 4294967295
bool Boolean value. It can take one of two values: 1 byte true or false
true or false.
2147483647
unsigned: 0 to 4294967295
bool Boolean value. It can take one of two values: 1 byte true or false
true or false.
float Floating point number. 4bytes +/- 3.4e +/- 38 (~7 digits)
Double Double precision floating point number. 8bytes +/- 1.7e +/- 308 (~15 digits)
long double Long double precision floating point number. 8bytes +/- 1.7e +/- 308
(~15 digits)
wchar_t Wide character. 2 or 4 bytes 1 wide
character
(~15 digits)
wchar_t Wide character. 2 or 4 bytes 1 wide
character
No comments:
Post a Comment