reproducible, & possibly configurable rounding

tripun goel tripun at gmail.com
Thu May 8 14:42:48 EDT 2014


On Thu, May 8, 2014 at 10:55 PM, Josh Berkus <josh at agliodbs.com> wrote:

> On 05/08/2014 08:03 AM, Bradley M. Kuhn wrote:
> >> ???
> >> > Ledger is written in Python
> > I respond with ??? in response, since Ledger-CLI is written in C++. :)
> >
>
> Sorry, I looked up ledger-cli on github and found an implementation in
> Python.  I'd assumed that that was the core project; apparently not.
>
> I will argue that fixing ledger-CLI's rounding problems should be out of
> scope for this project, a waste of time and money.  If it has rounding
> issues, then the answer is to abandon ledger-CLI for something else, or
> reimplement it using code which supports fixed-point arithmatic (maybe
> even that Python project I found).  Ledger-CLI's functionality is not
> that complex.
>
> I am aware of packages available for decimal representation in Python.
Ledger-cli uses integer rationals for internal representations and
calculations. This provide more accuracy than fixed point in long term. It
also uses correct rounding before displaying the floating string. The
problem is that you cannot set this display precision before hand. So if
you have a transaction less precise than the actual amount. For example, if
you have all the entries of the format $0.0 but the balance amount after
calculations amounts to $0.0169, it will be rounded to $0.0. This error is
carried further in register. Also you cannot set this precision by an
option as of now(I didn't find and I am waiting for an answer)  and I hope
to code that. It takes its cue from the entries parsed and the precision of
displayed amounts in the input file.
Another point is to prove by comparison between fixed point(decimal),
floating point(binary) and Integer rationals that the problem of accuracy
does not occur. This is possible by writing test which are sure to produce
rounding errors in floating point. Truncation errors in calculations while
using fixed-point and how this is tackled in ledger cli.


> This whole project is in serious danger of being consumed by yak-shaving.
>
>

Regards
Tripun Goel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sfconservancy.org/pipermail/npo-accounting/attachments/20140509/d8e43a9d/attachment.html>


More information about the npo-accounting mailing list