From bcae0c913958ae7bf7f004d854657b7ef98bbbcb Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 11 Mar 2020 10:31:28 +0100 Subject: [PATCH] App: [skip ci] reduce number of digits by 1 to display a NumberExpression See also: https://forum.freecadweb.org/viewtopic.php?f=3&t=44057 --- src/App/Expression.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index 46d0c01ac9..038562f497 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -1348,7 +1348,14 @@ void NumberExpression::negate() void NumberExpression::_toString(std::ostream &ss, bool,int) const { - ss << std::setprecision(std::numeric_limits::digits10 + 2) << getValue(); + // Restore the old implementation because using digits10 + 2 causes + // undesired side-effects: + // https://forum.freecadweb.org/viewtopic.php?f=3&t=44057&p=375882#p375882 + // See also: + // https://en.cppreference.com/w/cpp/types/numeric_limits/digits10 + // https://en.cppreference.com/w/cpp/types/numeric_limits/max_digits10 + // https://www.boost.org/doc/libs/1_63_0/libs/multiprecision/doc/html/boost_multiprecision/tut/limits/constants.html + ss << std::setprecision(std::numeric_limits::digits10 + 1) << getValue(); /* Trim of any extra spaces */ //while (s.size() > 0 && s[s.size() - 1] == ' ')