Logic Error with boost::lexical_cast

Dear all, I am quite new to boost and need some help in problem that I encountered using boost. I am trying to read a .dat file to convert some of the fields to double values. The line format I am trying to read is sth like this GRID* 1086030 7.23756775373e-5.002455787667412 When I use the code it throws a logic_error, I controlled whether I am reading a valid field to convert or not and it is true. So I am using boost::lexical_cast<double>(string..) to convert that into a double value. What might be the problem to throw a logic error.(I know that it is a logic error :-) but I could not figure that out.) I would appreciate some help. Regards

Hi lexical_cast is for converting numeric values to strings, numeric_cast is what you want

Hi, Sorry i'm wrong, lexical_cast does conversions both ways. Its performing the conversion of 7.23756775373e-5.002455787667412 internally and rounding it to 7.23756775373e-5.00.

7.23756775373e-5.002455787667412 If the exponential contains a decimal point or a integer greater than 255 then its beyond the limits of double.
participants (2)
-
Jan Stetka
-
umut tabak