Questions tagged [boost-lexicalcast]

4 questions
4
votes
2 answers

Boost's lexical_cast From double to string Precision

I'm working with a library that unfortunately uses boost::lexical_cast to convert from a double to a string. I need to be able to definitively mirror that behavior on my side, but I was hopping to do so without propagating boost. Could I be…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
3
votes
3 answers

boost lexical cast double to string giving invalid results

I am trying this: std::cout << boost::lexical_cast(0.0009) << std::endl; and expecting the output to be: 0.0009 But the output is: 0.00089999999999999998 g++ version: 5.4.0, Boost version: 1.66 What can I do to make it print what…
AbbasFaisal
  • 1,428
  • 2
  • 18
  • 21
2
votes
1 answer

Set precision of a double variable in 'string to double' using lexical cast

I have a string which has the value "496934.079" . I use boost::lexical_cast () to convert this into a double variable (named pVar). However the value stored in pVar after conversion is "496934" not "496934.079". The digits after the decimal…
Sjs
  • 213
  • 1
  • 3
  • 16
1
vote
1 answer

boost bad lexical cast: source type value could not be interpreted as target when converting a string to unsigned long long

the following piece of code that I compiled on wandbox.org is causing the following error. I don't understand why I am getting the error. // This file is a "Hello, world!" in C++ language by GCC for wandbox. #include #include…
gringo
  • 373
  • 2
  • 4
  • 15