I have strange problem with reading double data in my c++ program, why is c++ adding nines and how can i make him not to?
When i gave him 8.62400e+02 he save it as 862.39999999999997726 not 862.4
Thank you for any help!
I have strange problem with reading double data in my c++ program, why is c++ adding nines and how can i make him not to?
When i gave him 8.62400e+02 he save it as 862.39999999999997726 not 862.4
Thank you for any help!
You simply cannot express all values exactly in float
s or double
s, that's the difference to integers. If you want to get rid of the 9's when printing the value, use an appropriate precision specifier in your printf()
format string, this will most likely do the trick, but internally, it won't ever be exactly = 862.4.