[GNC] gnucash_user: rounding errors and significant digits

Bruce McCoy email_bnj_now at yahoo.com
Mon Aug 21 13:21:15 EDT 2023


Greetings to all of you,   

 
Ingnucash, you have developed a wonderful program. Thank you. 
  

Greatis my anticipation for using it, although there is at least one areaI do not understand. Could you please help me comprehend what ishappening in the calculations of gnucash compared with thecalculations of Federated Hermes?
FederatedHermes determines the number of shares traded by the currency amountof the trade divided by the price of the shares. For example, onceupon a time they charged me a $15.00 Annual Fiduciary Administrationfee. The share price was $6.26. To meet the fee they sold 2.396shares and recorded it on their statement as -2.396 shares, accurateto 1/1,000 of a share, for the transaction. As we see below thenumber of shares they reported was truncated from the more accuratefigure given below. 
   
AnnualFiduciary Administrative Fee of $15.00/Share price of $6.26 =2.3961661341853035143769968   
 05111821086261980830670926517571884984025559105431309904153354632587859425shares traded.   
Ingnucash, entering the fee of $15 and the number of shares as 2.396,results in gnucash reducing the shares in the fund by 2.4, changingthe fund and expense accounts by $15.02, and setting the trade priceat $6.2583.   
Gnucashunderestimates the trade price by (1-(6.2583/6.26))*100 = 0.02715 %.   
Gnucashcould use a longer fraction to generate a more accurate share price. This only requires that the fraction have more significant digits. If gnucash multiplied the $15.00 fee by2.3961661341853035143769968051118   
21086261980830670926517571884984025559105431309904153354632587859425shares, won't the result be a share price of $6.26. 
   
Mutualfunds seem to treat both the amount of the local currency tenderedand the price per share as decimal numbers of high precision e.g.$15.0000000000000000000 or $6.260000000000000000000000. They seem toconsider the number of shares traded as an approximation. Of coursethey add and subtract fractional numbers of shares. Where do we seethem dividing the transaction cost by the number of shares, includingfractional shares, to calculate the the price per share?   
Inevery mutual fund statement I have seen, the prices and the numbersof shares always agree from month to month. Aren't mutual funds astandard in calculation of financial values? Why do we not do thesame by incorporating more significant digits in the calculations?   
InEdit > Preferences > Numbers, Date, Time > Numbers >Force Prices to display as decimals, the maximum number of decimalplaces one can display is only 8 (eight). If this is close to thenumber of significant digits gnucash is currently using, could it bethat we might consider using, instead of, say, double binaryfloating-point method, a decimal floating-point arithmetic, e.x.http://speleotrove.com/decimal, as is done in financial andcommercial applications (like engineering) requiring exact, precisemeasurements, especially in applications having multiple trailingzeros achieved by scaling? 
   

 
Aswe know both the IEEE have standards (ex. IEEE 754) recommending andEuropean regulatory agencies have laws mandating working precision indecimal digits for calculations. Packages like the Java BigDecimalclass and the C decNumber package have been developed to providecompliance.   

 
Whydo we not avoid rounding errors? Why do we not enjoy the accuracyand precision that everyone else can? Well, we can increase theprecision of our calculations by increasing the number of significantdigits in the decimal representations of our numerical data.   

Bruce





|  | Virus-free.www.avast.com |



More information about the gnucash-user mailing list