Andreas Ries wrote:
Hi, I'm using the borland toolset 5.8.2 under Win XP and have a problem doing the following:
double val = 795.6352; string result = boost::lexical_cast <string> (val);
the resulting string is: "795.63520000000005" with boost 1_35_0 the resulting string is: "795.6352000000001" with boost_1_34_0 Can anybody help?
This describes a bug I just found as well. I didn't see any follow up to this message when I looked through my archived boost mail. Looks like boost::lexical_cast for double and float got broken between boost 1_33 and boost 1_34 and now changes the precision of the cast and introduces error, and this was never fixed. This could cause havoc on the application I'm maintaining, which uses lexical _cast extensively and expects a precision of 2 so our users don't ever have to look at a number like the ones above. Unfortunately, I can't revert to boost 1_33 because we switched to Visual Studio 9 for our windows port. We build on gcc 4.1.2 on Unix platforms and, as I already mentioned VS9 on Windows, and we get this problem everywhere. Is there a workaround for this or a fix in the pipeline? If not, I guess it's time to write our own string wrappers again, so we know what it's going to do >hurghle<. mike