On Fri, Nov 13, 2009 at 03:07:27AM +0000, Simon Slavin wrote:
> 
> 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.

That's why I wrote "logically".  Clearly, very, very clearly, int64_t
is not a float, has no mantissa, no exponent.  But you can use it as
though an int64_t were a real (well, rational) number.

> 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.

Yes.

> 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:

Tenths of pennies are also used though.  See just about any gas station
in the U.S.

Oh, I forgot, with 64-bit _signed_ ints you get one fewer digit of
precision than I wrote earlier.

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

Reply via email to