Setting precision on the command line

87 views
Skip to first unread message

Martin Michlmayr

unread,
Jul 1, 2012, 4:59:26 PM7/1/12
to ledge...@googlegroups.com
Let's say I have 2 funds in an account. Fund AAA is 10.123 EUR at
current market value and BBB is worth 20.123 EUR.

When my broker shows the market value of my whole account, they round
each account and add everything up, i.e. 10.12 + 20.12 = 30.24.

However, ledger keeps all the precision, calculates 10.123 + 20.123 =
30.246 and shows 30.25.

Is there a way so I can tell ledger - ideally on the command line - to
limit precision to 2 digits, so I'll get the same result as what my
broker shows?


Test case:

D 1000.00 EUR

2012-01-01 *
A 1 AAA @@ 10.00 EUR
A 1 BBB @@ 20.00 EUR
C

P 2012-07-01 AAA 10.123 EUR
P 2012-07-01 BBB 20.123 EUR

$ ledger -f a bal -V A
30.25 EUR A

--
Martin Michlmayr
http://www.cyrius.com/

John Wiegley

unread,
Jul 2, 2012, 8:17:33 PM7/2/12
to ledge...@googlegroups.com
>>>>> Martin Michlmayr <t...@cyrius.com> writes:

> Is there a way so I can tell ledger - ideally on the command line - to limit
> precision to 2 digits, so I'll get the same result as what my broker shows?

At present there is no "trap" for this. I'll have to think about it. It may
be really easy, or it might require some significant changes.

The problem is that you can rewrite the individual posting amounts (too fine),
and you can rewrite the final account totals (too coarse), but you can't
rewrite the individual account totals in between.

John

Martin Michlmayr

unread,
Jul 12, 2012, 12:12:07 PM7/12/12
to ledge...@googlegroups.com
* John Wiegley <jo...@newartisans.com> [2012-07-02 19:17]:
> > Is there a way so I can tell ledger - ideally on the command line - to limit
> > precision to 2 digits, so I'll get the same result as what my broker shows?
>
> At present there is no "trap" for this. I'll have to think about it. It may
> be really easy, or it might require some significant changes.

Thanks, John. I've filed a bug so this is tracked.
Reply all
Reply to author
Forward
0 new messages