C++ Numeric Data Types

C++ Numeric Data Types


Define :
    Numeric Data Types
In numerical datatypes, there are two basic data types as shown below:
  1. Integer Data Type
  2. Floating points Data Type(float and double)
 
You can use int when you need to store integers and whole number without decimals (e.g., 95 or 1000) and float or double when use you need a decimal number (e.g., 5.87 or 7.9715).
  • Integer Data Type
You can use int is use to store integers and whole numbers without decimals (e.g., 95 or 1000).
    The int keyword is used to indicate integers.
 
Example of int:
Output : 140
  • Floating points Data Type
float or double are to store floating-point numbers (e.g., 5.87 or 7.9715) and exponentials( e.g., 10E13)
 
The size of float is 4 bytes and the size of double is 8 bytes. Hence, double has two times the precision of float. To learn more, visit C++ float and double.
Example of float:
Output : 98.76
 
Example of double:
Output : 65.7699
As mentioned above, these two data types are also used for exponentials. For example,