Fix exception when converting to decimal values that reduce to N/1.

Before this the loop wouldn't terminate until the denominator had been
reduced to 0 and trying to create a GncRational with a 0 denominator
throws.
This commit is contained in:
John Ralls
2020-11-07 16:22:18 -08:00
parent d03dc07b8d
commit 2290fa7c22
2 changed files with 13 additions and 1 deletions

View File

@@ -368,7 +368,7 @@ GncNumeric::to_decimal(unsigned int max_places) const
rr_num *= factor;
rr_den *= factor;
}
while (!rr_num.isZero() && rr_num % 10 == 0)
while (!rr_num.isZero() && rr_num > 9 && rr_den > 9 && rr_num % 10 == 0)
{
rr_num /= 10;
rr_den /= 10;