From 41c81a71c1c432c2d5ff3342d2a570c19d01727b Mon Sep 17 00:00:00 2001 From: phkahler <14852918+phkahler@users.noreply.github.com> Date: Sat, 9 Jan 2021 16:57:38 -0500 Subject: [PATCH] Override minimum displayed digits as needed to avoid showing zero. --- src/solvespace.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/solvespace.cpp b/src/solvespace.cpp index 054c4908..4e458cf4 100644 --- a/src/solvespace.cpp +++ b/src/solvespace.cpp @@ -331,7 +331,13 @@ const char *SolveSpaceUI::UnitName() { std::string SolveSpaceUI::MmToString(double v) { v /= MmPerUnit(); - return ssprintf("%.*f", UnitDigitsAfterDecimal(), v); + int digits = UnitDigitsAfterDecimal(); + double minimum = 0.5 * pow(10,-digits); + while ((v < minimum) && (v > LENGTH_EPS)) { + digits++; + minimum *= 0.1; + } + return ssprintf("%.*f", digits, v); } static const char *DimToString(int dim) { switch(dim) {