Using cout to produce output -
double space = 4.0 - 1.9999999;
cout << space << endl;
Why am I not getting 2.0000001 instead? What should the type be or the numbers to make this 2.0000001?
cout << fixed << setprecision(7) << space << endl; Don't forget to include <iomanip>, and take care with expectations when it comes to floating point arithmetic. The results are often approximations and can suffer from accumulated errors. Read More
There's another way to set the flags, or you can use another output method, but that's essentially the normal way to override cout's convenience behavior. I can't think of any clever way off the top of my head that isn't too awkward to be reasonable. > Any thoughts? If it … Read More
Edited by stengeljjj