
1 Jun
2007
1 Jun
'07
7:57 p.m.
On 6/1/07, Alexander Nasonov <alnsn@yandex.ru> wrote:
Jonathan Franklin wrote:
FWIW, sending the double value to std::cout works as expected: double d = 72.35; std::string s = boost::lexical_cast<std::string>(d); printf("%s\n", s.c_str()); // prints 72.34999999999999 std::cout << d << std::endl; // prints 72.35
because default precision is 6. Try to set it to numeric_limits<double>::digits10 + 1.
Oops, good call. std::cout.precision(std::numeric_limits<double>::digits10 + 1); std::cout << d << std::endl; // prints 72.34999999999999 Jon