]> git.lyx.org Git - features.git/commit
Fix bug #9193: Spacing modification not exact
authorEnrico Forestieri <forenr@lyx.org>
Sat, 12 Jul 2014 17:12:08 +0000 (19:12 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Sat, 12 Jul 2014 17:12:08 +0000 (19:12 +0200)
commit5bd14af8871b8f87c2c73ca8392b7c72217ad72d
tree888d88cdf1048d234ea7d44ca5e09c4252dce466
parentb3735501c7952ec53600f94d90ae8e164300ca76
Fix bug #9193: Spacing modification not exact

The conversion from floating point to string performed by
boost:lexical_cast does not allow specifying a precision and,
for example, values such as 0.9 are resturned as 0.899999976.
The standard C++ way for performing the conversion is using
std::ostringstream which is exempt from this problem, even if
less efficient. For the sake of accuracy, boost::lexical_cast
is ditched in favor of the ostrinsgstream implementation.
In C++11 another option would be using std::to_string, but I
think it is not as efficient as the boost way and not worth
implementing through #ifdef's.
Incidentally, this patch would have also fixed #9190 and all
similar cases involving the use of convert<string>(float|double).
src/support/convert.cpp