I understand that when I am increasing precision I should get more precise result. But that is not quite clear from this example where I have increased the precision, but I am not getting correct result:
#include <iostream>
#include <iomanip>
int main()
{
using namespace std;
cout << setprecision(17);
double dValue;
dValue = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1;
cout << dValue << endl;
}
The output is 0.99999999999999989
Can someone explain me why is this happening ?