Avoid scientific notation in fraction part

This commit is contained in:
Klaus Basan
2019-07-22 23:12:02 +02:00
committed by Mat Sutcliffe
parent 2736539b49
commit e5205bef1f
2 changed files with 4 additions and 3 deletions

View File

@@ -141,7 +141,8 @@ namespace BlackMisc
{
double intpart;
const double fractpart = modf(value, &intpart);
const QString f = QString::number(fractpart);
const int prec = width >= 0 ? width + 1 : 10;
const QString f = QString::number(fractpart, 'f', prec); // avoid scientific notation
const QString fInt = f.length() < 3 ? QString("0") : f.mid(2);
if (width < 0) { return fInt; }
if (fInt.length() >= width) { return fInt.left(width); }