|
|
|
C++
Data Types
The following is a tutorials in data types of c++...i hope
this helps in some way...
When dealing with storage and interpretation of numbers in
C++, we have several different data types to represent them
with. The type and size of a number that we can represent
depends on the variable type that we choose for it. There are
two basic categories that non-rational (not in fractional
form) numbers fall into mathematically: integers and real
numbers (without taking into account complex numbers).
Integers - are whole numbers, positive and negative. All
integers are also real numbers.
Integers = {0,1,2,3,-2,-1, ...}
Real Numbers - include all positive and negative numbers with
fractional parts written past the decimal (or radix) point .
Real Numbers = {0,1,1.3,-2.65,1.00025, ...}
In the world of computer science, real numbers are represented
with a floating-point type.
Here is a chart of primitive variable types used to represent
numbers in C++:
Variable Type Represents
char -- Small Integer (one byte)
unsigned char-- Small Positive Integer (one byte)
short -- Integer
unsigned short -- Positive Integer
int -- Larger Integer
unsigned int -- Larger Positive Integer
long -- Even Larger Integer
unsigned long -- Even Larger Positive Integer
float -- Floating-point
double -- Floating-point with more accuracy
long double -- Floating-point with even more accuracy
NOTE: The range of numbers a data type can store depends on
the system platform you are using. If you are using a 32-bit
system such as Windows 95 and up an int will 32 bits (4
bytes). If you are using DOS an int will be 16-bits (2 bytes).
You should refer to the specific documentation for your system
to determine these values.
However, there are a couple of non-numerical* values that we
would like to represent in C++.
Boolean - a logical value of true or false.
Character - printable characters and special characters.
Here is how these are represented in C++.
Variable Type Represents Range
bool -- Boolean (Logical true or false) true or false
char -- System Character System Dependent
unsigned char -- System Character System Dependent
NOTE: Notice that character data types can also store a
numerical value that corresponds to a specific character. For
example, the ASCII value for 'A' is 65.
If the format of typing is in anyway unclear just let me
know...
-kolij-
|
|