On Thu, Jun 11, 2009 at 4:08 PM, revDAVE<c...@hosting4days.com> wrote:
> Php - MySQL - newbie question
>
> - Field type for american money - int(11) seems to work fine
>
> - but also I tried decimal(10,2)
>
> Is one a better choice than another for american money usage?
>
>
> --
> Thanks - RevDave
> Cool @ hosting4days . com
> [db-lists 09]

It depends on what you need to store, honestly. If all your dollar
amounts are integers, int would work fine. If you need decimals,
decimal(10, 2) would be fine for a lot of applications. However, a lot
of financial applications need a little more precision. SQL Server has
a money datatype that looks like it's about equivalent to decimal(19,
4) and a smallmoney type that looks like it's equivalent to
decimal(10, 4). That handles things like gas prices that always have
that extra 9/10 of a penny tacked onto them, or items that are 3 for a
dollar. If you enter a price of 0.33 in a decimal(10, 2) field,
multiplying that by 3 will result in 0.99, whereas three items priced
at 0.3333 will come to 0.9999, which when formatted to two digits will
round to 1.00.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to