Investment holdings floating point number math error

molehill6804
molehill6804 Member
edited February 2024 in Report a Bug

The calculations in the investment hub (/investing) appear to have a math error. I am trying to track cryptocurrency in the app, and I am seeing what appears to be floating point math errors causing my balance to be slightly off.

For example, in one of my accounts, the balance is reported as 0.044337430000000004shares. This is far more significant digits than the cryptocurrency has natively and happened when I added a small number of shares to my existing balance. I believe this is due to the app using some sort of floating point math leading to the extraneous digits at the end.

I believe that cryptocurrencies, much like currencies or shares, should instead be represented with so-called "Decimal" or "Currency" numbers to eliminate floating point arithmetic errors such as this. In an ideal world, the app would take into account the precision provided by the native blockchain to set the available number of decimal points (i.e. 10^-8 for Bitcoin and Litecoin, 10^-18 for Ether, etc.) to allow for accurate accounting.

Tagged:

Comments

This discussion has been closed.