Skip to content

Commit

Permalink
tolerances can be negative, thus the decimal precision check must be …
Browse files Browse the repository at this point in the history
…adapted
  • Loading branch information
donovaly authored and wwmayer committed Dec 3, 2020
1 parent 0baabca commit 8fe7ca0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Mod/TechDraw/App/DrawViewDimension.cpp
Expand Up @@ -724,12 +724,12 @@ std::string DrawViewDimension::formatValue(qreal value, QString qFormatSpec, int
#endif
// if abs(1 - userVal / formattedValue) > 0.1 we know that we make an error greater than 10%
// then we need more digits
if (abs(userVal - formattedValue.toDouble()) > 0.1 * userVal) {
if (abs(userVal - formattedValue.toDouble()) > 0.1 * abs(userVal)) {
int i = 1;
do { // increase decimals step by step until error is < 10 %
formattedValue = QLocale().toString(userVal, 'f', i);
++i;
} while (abs(userVal - loc.toDouble(formattedValue)) > 0.1 * userVal);
} while (abs(userVal - loc.toDouble(formattedValue)) > 0.1 * abs(userVal));
// We purposely don't reset the formatSpecifier.
// Why "%.1f" is overwritten for a value of e.g. "0.001" is obvious,
// moreover such cases only occurs when
Expand Down

0 comments on commit 8fe7ca0

Please sign in to comment.