[GNC] GnuCash_user: rounding errors and significant digits

john jralls at ceridwen.us
Tue Sep 26 12:49:56 EDT 2023



> On Sep 26, 2023, at 08:31, Tom Browder <tom.browder at gmail.com> wrote:
> 
> On Mon, Sep 25, 2023 at 20:07 Bruce McCoy via gnucash-user <
> gnucash-user at gnucash.org> wrote:
> ...discussion of GnuCash's handling of numbers...
> 
> Does GnuCash use the Gnu Multiple Precision Arithmetic (GMP) library?

No. Like all infinite precision numerical methods it allocates from the heap and that makes it too slow. GnuCash uses a pair of stack-allocated 128-bit integers (see https://github.com/Gnucash/gnucash/blob/stable/libgnucash/engine/gnc-int128.hpp) to compose rational numbers (https://github.com/Gnucash/gnucash/blob/stable/libgnucash/engine/gnc-rational.hpp) for computation that's reduced to int64_t-based rationals (https://github.com/Gnucash/gnucash/blob/stable/libgnucash/engine/gnc-numeric.hpp) for presentation and storage. Intermediate results are reduced to help prevent overflows and a variety of rounding techniques are implemented in https://github.com/Gnucash/gnucash/blob/stable/libgnucash/engine/gnc-rational-rounding.hpp.

Regards,
John Ralls



More information about the gnucash-user mailing list