On Fri, Jul 22, 2011 at 10:27 AM, WR Consulting <[email protected]> wrote:
> Rich, one of the things that I found quite surprising about SL when I
> first started "peeking under the hood" was its use of a floating-point
> type for monetary amounts.  Since most any decent database will
> support a fixed-point type, I would've selected that instead.
> Fixed-point calculations don't suffer from "drift" like floating-point
> ones do.  In fact, the value 0.10 (1/10) in binary floating point is
> not an exact value, but an infinitely repeating series.  What does all
> of this mean?  I discovered that if enough values are added up, such
> was in a reconciliation spanning a long time, they'll drift pretty
> badly.

If you look at the early LedgerSMB upgrade scripts from SQL-ledger,
one of the things we did can be done to solve the floating point
problem:

ALTER TABLE acc_trans ALTER COLUMN amount TYPE numeric;

This moves the amount column from a base 2 representation to a base
1000 representation, which can map losslessly to base 10.

I doubt that is the only issue though.  Since this may affect
LedgerSMB 1.2 as well, I'd be interested in finding out more about
this issue.

Best Wishes,
Chris Travers
_______________________________________________
SQL-Ledger mailing list
[email protected]
http://lists.ledger123.com/mailman/listinfo/sql-ledger

Reply via email to