[TriLUG] Money in mysql
Phillip Rhodes
mindcrime at cpphacker.co.uk
Thu Oct 14 04:32:18 EDT 2004
Matt Frye wrote:
> What's the best numeric type in mysql for dealing with money, i.e.
> dollars and cents? Float, decimal, fixed? Informed suggestions
> appreciated.
There's a train of thought amongst some folks that it's best
to store and calculate "money" amounts as integers, in terms of
cents, instead of floating point types in terms of dollars.
Ie, 1 dollar becomes '100' instead of '1.00'. The idea is to eliminate
the possiblity of rounding errors that can be introduced by conversions
to and from floating point types, and in floating point arithmetic
itself.
Outside of that, I know nothing specific to mysql to indicate
on field type over another.
TTYL,
Phil
More information about the TriLUG
mailing list