# C++ Data Types Numeric – Learn C++ Programming

Jul 8, 2020

Today, Our Topic is C++ Data Types Numeric of Learn C++ Programming. And I will talk about it concisely, C++ numerics data type has main three types.

The Types is:

• int (integer)
• double
• float

So, first Numeric data type is int (Integer), and it stores a whole number without decimals number, like a 25 and 105.

So, see the Example:

``````#include <iostream>
using namespace std;

int main () {
int myIntVal = 1020;
cout << myIntVal;
return 0;
}``````

Then, see the Output:

``1020``

If you write a code which, you use int myNub = 10.99; then the output will be 10 only. not the output 10.99. if you want to get output like that. then you have to use the float data type.

So, see the Example:

``````#include <iostream>
using namespace std;

int main () {
float myFloatNum = 9.11;
cout << myFloatNum ;
return 0;
}``````

Then, see the Output:

``9.11``

So, peoples, the float is a short number data type, but if want to use the maximum length of number, then you have to use double data type. Read the about Data Types and Variables.

So, see the Example:

``````#include <iostream>
using namespace std;

int main () {
double myDoubleNum = 19.11;
cout << myDoubleNum1;
return 0;
}``````

Then see the Output

``19.11``

## C++ Data Types Numeric difference between Float and Double

The accuracy of a floating-point value indicates how many digits the value can have after the decimal number points. So, the accuracy is only six (6) or seven (7) decimal digits, while “double” variables have an accuracy of about fifteen(15) digits, Therefore it is safe to use the “double” variable for most calculation.

## So, the Scientific Number

A floating-point is storing a long decimal number, So, the scientific with an “e” is to indicate the power of 10. Then, see the Example.

Example:

``````#include <iostream>
using namespace std;

int main () {
float float1 = 55e3;
double double1 = 15E3;
cout << float1 << "\n";
cout << double1;
return 0;
}``````

So, the is Output:

``````55000
15000``````

In this chapter, we have coved these topics, first How to use integer variable (int), and then second, How to use float and double data type variable, and then third is the difference between float and double data types.

So, Read our recent posts and Go to C++ Home

It's me Usama Arshad working as a Lecturer C++. I am a student of BSIT.