F
ferran
Hi, I'm trying to convert a string to a long double using streams but
for some reasing seems to give the wrong values, the idea is to do a
precise textual conversion without roundings or truncations, I though
about using strtold but this function is not portable hence that is
why I'm using streams, this is what I'm doing
//-------------------------------------------------------
std::stringstream oStream;
std::string sInput = "3.14159265358979323846";
long double dOutput = 0;
oStream << sInput;
oStream >> dOutput;
//-------------------------------------------------------
This is giving me a result in dOutput of 0.00564616105916946368 !!!!
This is quite strange cos it seems to work perfectly for any numeric
types smaller than 'long double', can anyone tell me what I'm doing
wrong?
Thanks for any offered help
<>Fernando
for some reasing seems to give the wrong values, the idea is to do a
precise textual conversion without roundings or truncations, I though
about using strtold but this function is not portable hence that is
why I'm using streams, this is what I'm doing
//-------------------------------------------------------
std::stringstream oStream;
std::string sInput = "3.14159265358979323846";
long double dOutput = 0;
oStream << sInput;
oStream >> dOutput;
//-------------------------------------------------------
This is giving me a result in dOutput of 0.00564616105916946368 !!!!
This is quite strange cos it seems to work perfectly for any numeric
types smaller than 'long double', can anyone tell me what I'm doing
wrong?
Thanks for any offered help
<>Fernando