Boost logo

Boost :

From: Jonathan Franklin (franklin.jonathan_at_[hidden])
Date: 2007-06-01 15:04:06


On 6/1/07, Alexander Nasonov <alnsn_at_[hidden]> wrote:
>
> I'm sure it's consistent with std::iostream behavior so it's not
> a bug :(

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

Reading 72.35 from std::cin works as expected in both cases:
  double d = 0.0;
  std::cin >> d;
  std::string s = boost::lexical_cast<std::string>(d);
  printf("%s\n", s.c_str()); // prints 72.35
  std::cout << d << std::endl; // prints 72.35

(MSVC8)

Jon

Jon


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