[TriLUG] Money in mysql

Tanner Lovelace clubjuggler at gmail.com
Thu Oct 14 09:10:11 EDT 2004


On Thu, 14 Oct 2004 05:57:06 -0400, Phillip Rhodes
<mindcrime at cpphacker.co.uk> wrote:
> Phillip Rhodes wrote:
> > Pretty precise,
> > but the problem then becomes if you multiply the result by
> > 7, you won't get back your original number.  This can cause
> > unexpected glitches if you're not careful.
> 
> I should have said, "you won't necessarily get back your original
> number."  And therein lies the rub.  Depending on what happens
> with the truncation / rounding, you may or may not get the
> results you intuitively expect, on any given occassion.

Yep.  Look up "catastrophic cancellation" in google to find out more
about that.  Actually, if you misspell it as "catastrophic cancelation"
you find this web page:

http://www.cs.princeton.edu/introcs/91float/

which speaks directly about representing financial data in Java.

Cheers,
Tanner



More information about the TriLUG mailing list