On 13 Nov 2009, at 12:34am, Nicolas Williams wrote: > On Thu, Nov 12, 2009 at 11:40:23PM +0000, Simon Slavin wrote: >> 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. > ^^^^^^^^^^^^^^^^^^^^^^^ > They use integer math to avoid floating point rounding issues, but > logically those integers are still real (or at least rational) numbers, > and so we can speak of base, mantissa and exponent. The precision > required is pretty large, much more than two digits.
Integers in all languages I'm aware of are not stored as mantissa/exponent, they're stored as bits with complete precision. You can say you need a particular number of bits, but you'll never lose the last bit (the 1s) just because your numbers have got too big. You'll get an overflow error instead. By 'two digits of precision' I was referring to cents for US dollars, pence for pounds sterling, etc.. Some currencies have no fractional part (e.g. Yen). And I was sure there were ... ah, here we are: http://www.worldatlas.com/aatlas/infopage/currency.htm Okay, so do not hardwire your code for two decimal places because you won't handle Kuwaiti dinar correctly. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users