Fix the smart truncate display in DbU::getValueString().

This commit is contained in:
Jean-Paul Chaput 2021-01-13 19:04:13 +01:00
parent 3b5a0f5bd2
commit 250ef29674
1 changed files with 9 additions and 3 deletions

View File

@ -341,9 +341,15 @@ namespace Hurricane {
} else if (mode & SmartTruncate) { } else if (mode & SmartTruncate) {
size_t dot = s.rfind( '.' ); size_t dot = s.rfind( '.' );
if (dot != string::npos) { if (dot != string::npos) {
size_t end = dot+1; size_t end = dot;
for ( ; end < s.size() ; ++end ) if (s[end] != '0') break; size_t nonzero = end;
if (end == s.size()) s.erase( dot ); for ( ; end < s.size() ; ++end ) {
if (s[end] != '0') nonzero = end;
}
if (nonzero == dot) s.erase( dot );
else {
if (nonzero < s.size()) s.erase( nonzero+1 );
}
} }
} }
if (unitPower != ' ') s += unitPower; if (unitPower != ' ') s += unitPower;