samedi 1 avril 2017

A loss of precision

Hello everybody I have a problem with a loss a precision. Indeed if I have a double string which is equals to "123.546123" and if I want to convert to a double with atof I get only 123.546. How can I do to fix this ?

Here is my code :

#include <iostream>

int main(){

std::string a = "123.123456";
double b = atof(a.c_str());

std::cout << a << std::endl;
std::cout << b << std::endl;

return EXIT_SUCCESS;
}

Thank you very much :)

Aucun commentaire:

Enregistrer un commentaire