Jim,

 

Inyour response of Mon, Aug 21, 2023 at 5:00 PM via GnuCash-user yousaid:




 "Logically,$value = $price/share * #shares, and this should be 
preciseequality."

 

 GnuCash“stores the price as a rational number, a ratio between numeratorand 
denominator,”




 "price= 15000/2396 = 3750/599 $/share...the more accurate 3750/599."

 

Let'ssee what GnuCash, excellent program that it is, does with the exact(price 
per share) fraction it was given to use. If GnuCash does thecalculation 
correctly, then 

$value= $price/share * #shares will be a precise equality. If GnuCashdoes the 
calculation incorrectly, then 

$value= $price/share * #shares will not be a precise equality. 




Yousay that 3750/599 is "the more accurate." How precise isit? Let's see.

 

2.396shares * (3750/599) $/share = 2.396 shares 
*6.260434056761268781302170283806343906510851419

3171953255425709515859766277128547579298831385642737 $/share = 
$15.000000000000000000000000

0000000000000000000006839999999999999999999999999999999999999999999999997852. 
So, thefraction is accurate to 51 significant digits. With 51 
significantdigits, one would be precise 
to$23,456,789,012,345,678,901,234,567,890,123,456,789,012,345,678,901.23.Even 
if you had only 17 significant digits, you could have aprecision up to 
$123,456,789,012,345.67. Ifyou asked me, even if I reached 100, my portfolio 
would never comeclose to even the much more modest, second estimate.)




Onmy Windows 10 machine, GnuCash shows 6 + 156/599 = 6.260434057$/share (10 
significant digits). In a spreadsheet preferencessetting, we see about the same 
number of significant digits. In thisexample, GnuCash is losing 41 significant 
digits. Why?

 

Inexpression-parser.c, we find that on Wednesday June 21 2000 TerryBoldt 
informs us "The division operation is done in 'double'since I do not think that 
anybody really wants (9 / 2) to equal 4instead of 4.5 for financial operations."

Scanningthe source for "long double" returned nothing. 

 

Onx86, Double is 53bit mantissa or 16 round safe digits. Long Double"tends to 
be the 80-bit extended format: 64bits of mantissa,15bits of exponent, probably 
going to be around 18 round safedigits."(1) So, I suppose we lost a lot of 
significant digitshere in GnuCash. If this is not the case, please help. If 
this isthe case, we need more precision in GnuCash. 




InSeptember of 2003, we have a lot better options than Terry did in2000. What 
are some of the ones we prefer?

 

BestRegards,

Bruce







(1) 
https://stackoverflow.com/questions/476212/what-is-the-precision-of-long-double-in-c



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

_______________________________________________
gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
-----
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.

Reply via email to