Popular Google Pages:
◕ Send your story to RiyaButu.com and get ₹ 500/- Details..
◕ Bengali Story writing competition. Details..
◕ This article is regarding
Advantages and Disadvantages of floating point number
Compasiron of floating point number and integer
Last updated on: 01st January 2017.
◕ Disadvantages of floating point numbers.
If we use floating point numbers in our program then we should take care of the following things.
Floating point operations are usually slightly slower than integer operations.
We can lose precision in floating point applications.
◕ Let have an example:
using namespace std;
float a = 1.234E12f;
float b = a + 1.0f;
cout << " The value of a is: " << a << endl;
cout << " We substract a from b. " << endl;
cout << " The result is: " << b - a << endl;
The output result will be like this:
The value of a is: 1.234E12f
We substract a from b.
The result is: 0
In the above example the we add 1 with the value a. The new value is b.
Then we substract a from the value b.
Now the result should be 1.
But the result is 0.
Because type float can represent only the first 6 or 7 digits in a number.
So trying to change the 12th digit of a has no effect on the value.
◕ Advantages of floating point number over integer.
- Only floating point numbers can represent values between two integers.
Integer can not do this.
- Floating point numbers can represent much greater range of values than integers.
Because of the scaling factor of the floating point numbers.
Why floating point numbers are called floating point numbers?
Floating points numbers
Different way to write Floating-Point Numbers in C++
climits in C++
sizeof Operator in C++
Bits & Bytes
Integer Type in C++
Signed char and Unsigned char in C++
Rules for Variable Names
Variable in C++
Fundamental Data Types & Compound Data Types
Top of the page