Fix sigfigs(n) rounding to work when the input is bigger tnan 10**n.

For example rounding 1234567/1 to 6 significant figures would fail.
This commit is contained in:
Mike Alexander
2017-08-22 00:47:08 -04:00
parent 57638161f2
commit 29a92431cb
2 changed files with 6 additions and 2 deletions

View File

@@ -171,7 +171,9 @@ GncRational::sigfigs_denom(unsigned figs) const noexcept
++digits;
val /= 10;
}
return not_frac ? powten(figs - digits - 1) : powten(figs + digits);
return not_frac ?
powten(digits < figs ? figs - digits - 1 : 0) :
powten(figs + digits);
}
GncRational