gnucash stable: Bug 799268 - Cannot write a check over $1000

Christopher Lam clam at code.gnucash.org
Wed Apr 10 01:34:24 EDT 2024


Updated	 via  https://github.com/Gnucash/gnucash/commit/8c94132f (commit)
	from  https://github.com/Gnucash/gnucash/commit/0447e8da (commit)



commit 8c94132f1373480b55c0ca165f8434e29df0519e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Apr 10 13:29:10 2024 +0800

    Bug 799268 - Cannot write a check over $1000
    
    this is caused by d52d226e5b which caused log_val, pow_val, this_part
    to be kept as float instead of the original algorithm which required
    casting to int.

diff --git a/libgnucash/app-utils/gnc-ui-util.cpp b/libgnucash/app-utils/gnc-ui-util.cpp
index bfbf5bd0e3..764fb22953 100644
--- a/libgnucash/app-utils/gnc-ui-util.cpp
+++ b/libgnucash/app-utils/gnc-ui-util.cpp
@@ -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]),
@@ -1582,7 +1581,7 @@ 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, ' ');
@@ -1590,7 +1589,7 @@ integer_to_words(gint64 val)
 
     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, ' ');
     }



Summary of changes:
 libgnucash/app-utils/gnc-ui-util.cpp | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)



More information about the gnucash-changes mailing list