That is an interesting way to store money. We developed a fixed point arithmetic library of arbitrary precision using the algorithms described by Knuth in his semi-numerical algorithms volume and using standard DECIMAL(n,m) definition. Rounding is precise using an algorithm which does not drift and intermediate. Finally the numbers are stored in display format, right justified and with leading spaces and signs so that they can be displayed in HTML pages or printed output without reformating.

The arithmetic is obviously not suited to intensive calculation but is well suited to money usage where the absence of radix changes and edit conversions more than compensates for the arithmetic overhead, helped by using effcient arithmetic algorithms. Another advantage is that it makes inserting numbers in report tables absolutely trivial. They automatically line up in right justified columns.

It was a fairly simple exercise to graft this number system into Sqlite, really only requiring that the regular behaviour of giving a DECIMAL type numeric affiliation be altered to text affiliation to stop Sqlite from translating the formatted, fixed point numbers to floating point.

RohitPatel9999 wrote:
While doing currency math, a useful money class at following link, may be
used as a a reference.

http://www.di-mare.com/adolfo/p/money.htm
Yet Another C++ Money Class (by Adolfo Di Mare), The C Users Journal, Vol.10
No.4, pp [58-64], April 1992

Rohit.


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to