I am trying to convert a string to a double or float in C++, but the result is not exact. For example:
double d1 = stod("2.16"); //d1 ends up being 2.1600000000000001
float f1 = stof("2.16"); //f1 ends up being 2.16000009
Is it possible to convert "2.16" to the actual value 2.16 ( 2.16000000 float or 2.1600000000000000 double) using C++ libraries?
I need the exact values for some calculations so I don't need it to be printed as 2.16, I need the exact number.
 
     
    