[GNC] gnucash_user: rounding errors and significant digits
Bruce McCoy
email_bnj_now at yahoo.com
Thu Sep 14 17:51:38 EDT 2023
Jim,
Whatare some of the options available to GnuCash programmers today toimprove precision? Here is one group.
Decimal-FloatingArithmetic
GeneralDecimal Arithmetic
http://speleotrove.com/decimal
http://speleotrove.com/decimal/#decNumber
http://speleotrove.com/decimal/#links
http://speleotrove.com/decimal/#implement
ThedecNumber Library Version 3.68
https://speleotrove.com/decimal/decnumber.html
decimal— Decimal fixed point and floating point arithmetic
https://speleotrove.com/decimal/decarith.html
C++libraries Decimal-Arithmetic
GMP
https://gmplib.org/
GNUMPFR Library
https://www.mpfr.org/
https://www.mpfr.org/ports.html
https://github.com/microsoft/vcpkg.git (Windows)
mpdecimal
https://www.bytereef.org/mpdecimal/
Java
ClassBigInteger
https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html
Usesof Class java.math.BigDecimal
https://docs.oracle.com/javase/8/docs/api/java/math/class-use/BigDecimal.html
Python Decimal-Arithmetic
15.Floating Point Arithmetic: Issues and Limitations python
https://docs.python.org/3/tutorial/floatingpoint.html
cdecimal- Python module (2.7 – 3.2)
https://www.bytereef.org/mpdecimal/doc/cdecimal/index.html
DecimalArithmetic Functions
https://learn.microsoft.com/en-us/previous-versions/windows/desktop/automat/decimal-arithmetic-functions?redirectedfrom=MSDN
Listof arbitrary-precision arithmetic software
https://en.wikipedia.org/wiki/List_of_arbitrary-precision_arithmetic_software
IEEE754-2008 revision
IEEE 754-2008 revision - Wikipedia
|
|
| |
IEEE 754-2008 revision - Wikipedia
IEEE 754-2008 (previously known as IEEE 754r) is a revision of the IEEE 754 standard for floating-point arithmet...
|
|
|
Justto name two that probably everyone in this area knows, the GNUMultiple Precision Arithmetic Library version 6.3.0 and the MPFRMultiple Precision Floating Point Reliable Library were released in2023. I have no idea which of all these resources would be preferredby the understaffed and overworked GnuCash programmers.
Whatcan we do while awaiting a, say, decimal arithmetic or arbitraryprecision arithmetic software or some other excellent solution? Ifthe GnuCash community would like to have Gnucash software match thestatements from the investment firms calculating their holdings orthe members' own records, we could consider making a suggestion whichwould be relatively easy to code.
Currently,given the cost of the transaction and the number of shares traded,GnuCash calculates the price per share. On occasion, the Gnucashcalculation results are unexpected. In our example at hand, you find"Logically, $value = $price/share * #shares, and this should beprecise equality. But is possible for a brokerage statement to reportvalues which do not have precise equality. It sounds like FederatedHermes reported $15.00 = $6.26 * 2.396, but the actual $value of this$price and #shares is $14.99896, a difference of $0.00104."
Inthis example, if we could allow the user to enter $15.00, we wouldhave a solution, albeit a manual one.
GnuCashcalculates $value = $price/share * #shares. A screen showing thosethree results in data-entry fields instead of read-only fields wouldallow the user to change the aberrant result, which could be saved. The computer could be instructed to not re-calculate these threevalues again, until, say, the user changed one of them to null orzero. Such a process is relatively simple to program. It wouldserve the purpose until a perfect solution was developed.
Isthe GnuCash community be interested in having the values in GnuCashand the brokerage statements be identical?
Ifyou are a member of the GnuCash community, here is an invitation toexpress yourself concerning this topic. Feel free to comment
BestRegards,
Bruce
| | Virus-free.www.avast.com |
More information about the gnucash-user
mailing list