Discussion:
HELP ! With Money type
(too old to reply)
Terry Hampton
2004-07-23 12:36:41 UTC
Permalink
Everyone,

Just ran across an odd situation.
I have defined a field:

amount | money | not null default ''

Works fine until the dollar amounts get
very large - into the tens of millions.
At that point, the actual amount stored
becomes very unpredictable.

I just saved a record via a simple
front end App. I entered 56,000,000
When I retrieved the record i got:
$13,050,327.04 !!

Any thoughts ?

ENVIRONMENT:
Linux 2.4.20-20.7smp
psql (PostgreSQL) 7.2.3

Thank you,
Terry
--
Terry L. Hampton
Project Manager
LimaCorp, LLC www.limacorp.com
513.587.1874



---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org
Oliver Elphick
2004-07-23 13:20:43 UTC
Permalink
Post by Terry Hampton
Everyone,
Just ran across an odd situation.
amount | money | not null default ''
Works fine until the dollar amounts get
very large - into the tens of millions.
At that point, the actual amount stored
becomes very unpredictable.
I just saved a record via a simple
front end App. I entered 56,000,000
$13,050,327.04 !!
Any thoughts ?
The Money type is deprecated. It uses a floating point representation,
which is not good for precise values.

Use DECIMAL instead - e.g. DECIMAL(12,2)


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html
Tom Lane
2004-07-23 14:13:00 UTC
Permalink
Post by Oliver Elphick
The Money type is deprecated. It uses a floating point representation,
which is not good for precise values.
Actually the underlying storage is integer (int4), which is precise but
has a very limited range. Terry is seeing overflows (which are
evidently not being tested for :-().

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Loading...