Override minimum displayed digits as needed to avoid showing zero.

pull/889/head
phkahler 2021-01-09 16:57:38 -05:00
parent bd41485ebe
commit 41c81a71c1
1 changed files with 7 additions and 1 deletions

View File

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