Skip to content

Commit

Permalink
Bug 799268 - Cannot write a check over $1000
Browse files Browse the repository at this point in the history
this is caused by d52d226 which caused log_val, pow_val, this_part
to be kept as float instead of the original algorithm which required
casting to int.
  • Loading branch information
christopherlam committed Apr 10, 2024
1 parent 0447e8d commit 8c94132
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions libgnucash/app-utils/gnc-ui-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,19 +1561,18 @@ integer_to_words(gint64 val)

while (val >= 1000)
{
auto log_val = log10(val) / 3 + FUDGE;
auto pow_val = exp(log_val * 3 * G_LN10) + FUDGE;
auto this_part = val / pow_val;
int log_val = log10(val) / 3 + FUDGE;
int pow_val = exp(log_val * 3 * G_LN10) + FUDGE;
int this_part = val / pow_val;
val -= this_part * pow_val;
auto tmp = integer_to_words(this_part);
g_string_append_printf(result, "%s %s ", tmp,
gettext(big_numbers[static_cast<int>(log_val)]));
g_string_append_printf(result, "%s %s ", tmp, gettext(big_numbers[log_val]));
g_free(tmp);
}

if (val >= 100)
{
auto this_part = val / 100;
int this_part = val / 100;
val -= this_part * 100;
g_string_append_printf(result, "%s %s ",
gettext(small_numbers[this_part]),
Expand All @@ -1582,15 +1581,15 @@ integer_to_words(gint64 val)

if (val > 20)
{
auto this_part = val / 10;
int this_part = val / 10;
val -= this_part * 10;
g_string_append(result, gettext(medium_numbers[this_part]));
g_string_append_c(result, ' ');
}

if (val > 0)
{
auto this_part = val;
int this_part = val;
g_string_append(result, gettext(small_numbers[this_part]));
g_string_append_c(result, ' ');
}
Expand Down

0 comments on commit 8c94132

Please sign in to comment.