FUNDAMENTAL DATA TYPE
The values of variables are stored somewhere in an unspecified location in the computer memory as zeros and ones. Our program does not need to know the exact location where a variable is stored; it can simply refer to it by its name. What the program needs to be aware of is the kind of data stored in the variable. It’s not the same to store a simple integer as it is to store a letter or a large floating-point number; even though they are all represented using zeros and ones, they are not interpreted in the same way, and in many cases, they don’t occupy the same amount of memory.
Fundamental data types are basic types implemented directly by the language that represent the basic storage units supported natively by most systems. They can mainly be classified into:
- Character types: They can represent a single character, such as
'A'
or'$'
. The most basic type ischar
, which is a one-byte character. Other types are also provided for wider characters. - Numerical integer types: They can store a whole number value, such as
7
or1024
. They exist in a variety of sizes, and can either be signed or unsigned, depending on whether they support negative values or not. - Floating-point types: They can represent real values, such as
3.14
or0.01
, with different levels of precision, depending on which of the three floating-point types is used. - Boolean type: The boolean type, known in C++ as
bool
, can only represent one of two states,true
orfalse
.
Here is the complete list of fundamental types in C++:
#f0f0f0;”>Group | #f0f0f0;”>Type names* | #f0f0f0;”>Notes on size / precision |
---|---|---|
Character types | char |
Exactly one byte in size. At least 8 bits. |
char16_t |
Not smaller than char . At least 16 bits. |
|
char32_t |
Not smaller than char16_t . At least 32 bits. |
|
wchar_t |
Can represent the largest supported character set. | |
Integer types (signed) | signed char |
Same size as char . At least 8 bits. |
signed short int |
Not smaller than char . At least 16 bits. |
|
signed int |
Not smaller than short . At least 16 bits. |
|
signed long int |
Not smaller than int . At least 32 bits. |
|
signed long long int |
Not smaller than long . At least 64 bits. |
|
Integer types (unsigned) | unsigned char |
(same size as their signed counterparts) |
unsigned short int |
||
unsigned int |
||
unsigned long int |
||
unsigned long long int |
||
Floating-point types | float |
|
double |
Precision not less than float |
|
long double |
Precision not less than double |
|
Boolean type | bool |
|
Void type | void |
no storage |
Null pointer | decltype(nullptr) |
* The names of certain integer types can be abbreviated without their signed
and int
components – only the part not in italics is required to identify the type, the part in italics is optional. I.e., signed short int
can be abbreviated assigned short
, short int
, or simply short
; they all identify the same fundamental type.
Recuperado de: http:/
Para aquellos atascados que sólo quieren saber lo que necesitan, hay 5 tipos de datos para las variables. Son string, int, float, long y bool.
El tipo string es meramente para texto.
El tipo int es intiger que es para números enteros.
El tipo float es un número que admite números con puntos decimales.
El tipo long es para números de gran valor.
El tipo bool es solamente para dar un valor de true o false.
Para funciones hay un valor llamado voit que es para que imprima un valor sin necesidad de poner un cout. Tener mucho cuidado con las funciones a utilizar sobre todo en las funciones.
#TC1017
#MASTERY09
Fundamental Data Type by Juan Abdiel is licensed under a Creative Commons Attribution 4.0 International License.