On 12 Nov 2009, at 7:17pm, Peter Haworth wrote:

> Just to be sure I get my calculations correct, the suggestion is that  
> all currency amounts should be stored in the database as whole numbers  
> in fields of type INTEGER.  Calculations would be done using the whole  
> numbers and I'll need some routines to convert between the database  
> format and the display format.  Do I have that right?

Exactly.  I'm familiar with lots of big pieces of bank software and that's how 
they do it.

There's still some possibility for confusion, however: how many places of 
decimals do you use for each currency ?  As far as I know, no currently traded 
currency uses more than two digits of precision.  Some systems use two digits 
for dollars (because that's the actual smallest unit you can trade in it).  But 
some use four digits for every currency because it makes the library routines 
simpler, betrays rounding problems in your code, and allows for figures to be 
rounded later.  It's one of the unsettled problems of financial software.

Since you probably won't have to deal with multi-currency rounding problems I'd 
recommend you stick to two digits unless advised not to by someone who knows 
exactly what you're doing.

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

Reply via email to