Boost logo

Boost :

From: Preston A. Elder (prez_at_[hidden])
Date: 2007-05-31 07:37:04


This may have been posted before, but I did not see it or the solution.

This code:
double d = 72.35
std::string = boost::lexical_cast<std::string>(d);

Results in the string 72.3499999999999999999
However printf("%f\n", d);
Results in 72.350000

Any reason for this - or more importantly, any way to fix it and prevent
it happening again?

PreZ :)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk