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>(double) or
int ::abs(int)? Now it is explicit, and the code does not change in subtle
ways if somebody removes the using statement.
This commit is contained in:
Georg Baum 2015-06-28 11:22:42 +02:00
parent 6c3a6ea9bd
commit b8eb4fffee

View 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) {