]> git.lyx.org Git - features.git/commitdiff
Make it explicit that we need floating point abs
authorGeorg Baum <baum@lyx.org>
Sun, 28 Jun 2015 09:22:42 +0000 (11:22 +0200)
committerGeorg Baum <baum@lyx.org>
Sun, 28 Jun 2015 09:27:17 +0000 (11:27 +0200)
The 'using namespace std' at the top of the file makes it quite difficult to
understand which abs is used: double std::abs<double>(double) or
int ::abs(int)? Now it is explicit, and the code does not change in subtle
ways if somebody removes the using statement.

src/support/lstrings.cpp

index 0036d16274941a3448198e8f68ec19492b1fe31c..3a081a77012be36c8ad441346b5e93eba39f0b55 100644 (file)
@@ -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<int>(round(logarithm)), 0)) << x;
        string result = os.str();
        if (result.find('.') != string::npos) {