On Sun, Apr 13, 2008 at 07:37:33PM +0200, Aladdin Lampé wrote:
> In my opinion (please tell me if I'm wrong), your method only works if
> you want to *display* the values in your column, and if the decimal
> precision doesn't change form line to line.
> 
> I would like to be able to perform operations (+, /, %, etc.) and to
> store intermediary results into other columns (such as x% of the
> value, etc.), which may have an arbitrary precision, and - only at the
> end - round the result to cents/pennies etc. This is required into the
> technical specifications provided by my client, because high precision
> matters for them. Indeed, an error of 0.01$ on 10,000,000 lines would
> lead to a significant error at the end...

The proposed method allows you do perform arithmetic operations using
SQLite's built-in operators and functions.

If the greatest error your customer is willing to accept is, say, one
part in a million (that is, a millionth of a cent), then using 64-bit
would allow you to represent values up to ~ 10e13 -- 10 trillion, not so
much, but perhaps good enough for you.

If the tolerance is more like one in 10,000 ($0.0000001), then you can
represent up to ~ 1,000 trillion as the largest value.  That's still
pretty small, IMO, but almost certainly good enough for you.

You can adjust where you put the virtual fixed point.  If you can't find
a suitable break then you should consider your arbitrary precision
extended function function scheme (or a database engine that provides
the features you need).

Nico
-- 
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to