
You are watching: The numeric data types in c++ are broken into two categories:
Although C++ offers many data types, in the exceptionally broadest feeling there are only two: numeric and also character. Numeric dara varieties are damaged into two added categories: integer and floating point. Integers are entirety numbers like 12, l57, -34, and 2. Floating-point numbers have a decimal allude, like 23.7, 189.0231, and 0.987.
Integer File Types
Integer variables deserve to just host entirety numbers.
Integer Example

NOTE:The data type sizes and also varieties displayed in Table 2-6 are typical on many devices. Depending on your operating mechanism, the sizes and ranges may be various.Literals: Any consistent worth composed in a routine.The sizeof operator will certainly report the number of bytes of memory supplied by any kind of data form or variable.
Integer Examples
0000 | 0 | 0000 | 0 | 1000 | -8 |
0001 | 1 | 0001 | 1 | 1001 | -7 |
0010 | 2 | 0010 | 2 | 1010 | -6 |
0011 | 3 | 0011 | 3 | 1011 | -5 |
0100 | 4 | 0100 | 4 | 1100 | -4 |
0101 | 5 | 0101 | 5 | 1101 | -3 |
0110 | 6 | 0110 | 6 | 1110 | -2 |
0111 | 7 | 0111 | 7 | 1111 | -1 |
1000 | 8 | 0 indicates positive | 1 indicates negative | ||
1001 | 9 | ||||
1010 | 10 | ||||
1011 | 11 | ||||
1100 | 12 | ||||
1101 | 13 | ||||
1110 | 14 | ||||
1111 | 15 |
Overflow
Overflow is the case where you try to store a number that exceeds the maximum range for the data type. When you attempt to store too big of a positive or negative number, the binary representation of the number is corrupted and you gain a meaningmuch less or erroneous result.Underflow
Underflow is the instance wbelow you attempt to store a number that exceeds the minimum range for the data form. When you try to save also smevery one of a positive or negative number, the binary depiction of the number is corrupted and you get a meaningless or erroneous result.Floating-Point Data Type
Floating-suggest data species are provided to specify variables that can organize genuine numbers.In C++, there are three data varieties that have the right to represent floating-allude numbers.floatdoublelengthy double
Floating-Point Documents Example

NOTE:There are no unsigned floating-point data species. On all makers, variables of the float, double, and lengthy double data types can keep positive or negative numbers.Computers typically usage E notation to reexisting floating-point values. In E notation, the number 47,281.97 would certainly be 4.728197E4. The part of the number before the E is the mantissa, and the part after rhe E is the power of 10. When a floating-point number is stored in memory, it is stored as the mantissa and the power of 10.
The Char File Type
The char data form is provided to keep individual characters. A varaible of the char data form have the right to hold one character at a time. Although the char data type is used for storing characters, it is actually an integer information type that typically offers 1 byte of memory. (The dimension is device dependent. On some devices, the char data kind is bigger than 1 byte.)The reason an integer data kind is used to save personalities is bereason characters are internally stood for by numbers. Each character is assigned a distinct number.See more: Que Se Puede Llevar En El Equipaje A Estados Unidos En Avión
The most commonly provided strategy for encoding personalities is ASCII, which means the Amerideserve to Standard Code for Information Interadjust.When a character is srored in memory, it is actually the numeric code that is stored. When the computer system is instructed to print the worth on the display screen, it screens the character that synchronizes with the numeric code.
The Char File Example

The bool File Type
Expressions that have actually a true or false value are dubbed Boolean expressions. Boolean variables are set to either true or falseThe bool Documents Example

NOTE:The value true is represented in memory by the number 1, and false is stood for by 0.Boolean worths are advantageous for evaluating problems that are either true or false.When the boolalpha format flag is collection, bool values are inserted/extracted by their textual representation: either true or false , rather of integral values.
Declaring Variables With the auto Key Word
* C++ 11 introduces an different means to specify variables, using the auto key word and also an initialization value. Here is an example:       auto amount = 100; ← int
* The auto key word tells the compiler to recognize the variable"s data type from the initialization value:      auto interestRate = 12.0; ← double