From: Georg Baum Date: Sun, 28 Jun 2015 09:22:42 +0000 (+0200) Subject: Make it explicit that we need floating point abs X-Git-Tag: 2.2.0alpha1~484 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=b8eb4fffeeeb97799000b8ef2967b0945698b9fd;p=features.git Make it explicit that we need floating point abs The 'using namespace std' at the top of the file makes it quite difficult to understand which abs is used: double std::abs(double) or int ::abs(int)? Now it is explicit, and the code does not change in subtle ways if somebody removes the using statement. --- diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp index 0036d16274..3a081a7701 100644 --- a/src/support/lstrings.cpp +++ b/src/support/lstrings.cpp @@ -1407,7 +1407,7 @@ std::string formatFPNumber(double x) os << std::fixed; // Prevent outputs of 23.4200000000000017 but output small numbers // with at least 6 significant digits. - double const logarithm = log10(abs(x)); + double const logarithm = log10(fabs(x)); os << std::setprecision(max(6 - static_cast(round(logarithm)), 0)) << x; string result = os.str(); if (result.find('.') != string::npos) {