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.
- Character Data type
- Integer Data type
- Floating Point Data type
- Enumeration Data type
- Boolean Data type
Name
|
Bytes*
|
Description
|
Range*
|
char
|
1
|
character or integer 8 bits
length.
|
signed: -128 to 127
unsigned: 0 to 255 |
short
|
2
|
integer 16 bits length.
|
signed: -32768 to 32767
unsigned: 0 to 65535 |
long
|
4
|
integer 32 bits length.
|
signed:-2147483648 to
2147483647
unsigned: 0 to 4294967295 |
Int
|
*
|
Integer. Its
length traditionally depends on the length of the system's Word type,
thus in MSDOS it is 16 bits long, whereas in 32 bit systems (like Windows
9x/2000/NT and systems that work under protected mode in x86 systems) it is
32 bits long (4 bytes).
|
See short, long
|
float
|
4
|
floating point number.
|
3.4e + / - 38 (7 digits)
|
double
|
8
|
double precision floating point
number.
|
1.7e + / - 308 (15 digits)
|
long double
|
10
|
long double precision floating
point number.
|
1.2e + / - 4932 (19 digits)
|
bool
|
1
|
Boolean value.
It can take one of two values: true
or false
NOTE: this is a type recently added by the ANSI-C++ standard. Not all
compilers support it. Consult section bool type for compatibility
information.
|
true
or false
|
wchar_t
|
2
|
Wide
character. It is designed as a type to store international characters of a
two-byte character set. NOTE: this is a type recently added by the ANSI-C++
standard. Not all compilers support it.
|
wide characters
|
No comments:
Post a Comment