simonmichael / hledger_site

The repo for hledger.org, the hledger project's website.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

haskell precision

jbrodriguez opened this issue · comments

I have an issue with the following transaction

2022-01-01 Bitcoins
    assets:binance:wallet                               USDT-500.00
    assets:binance:crypto    0.01335609 BTC @ USDT37436.1

If you calculate the value of transaction in the 2nd account it equals 499.999920849

In order to get the correct value, the unit price should be as follows

2022-01-01 Bitcoins
    assets:binance:wallet                               USDT-500.00
    assets:binance:crypto    0.01335609 BTC @ USDT37436.10592621044

I got this number by running the division in the haskell ghc.

I can solve this by doing @@ total_price instead of @ unit_price, but I kind of lose that unit price value in the journal.

Any suggestions ?

Correct me if I'm wrong, but this seems like a problem with hledger itself rather than the website. If so, could you raise this issue at the main site? https://github.com/simonmichael/hledger/

Could you also clarify how this is arising? In particular, is the transaction you post something that is in your journal, or is it the output of a print command? If the latter, could you include the original journal transaction?

hledger internally keeps track of precision and uses some heuristic rules to display values which balance accuracy and conciseness, but there are always trade-offs. If you could let us know how this arises it will give us the best idea how to improve.

you're right, will open in the correct repo