I want more Money (the data type, of course! :-))

Started by Carlos Morenoalmost 25 years ago7 messagesgeneral
Jump to latest
#1Carlos Moreno
moreno@mochima.com

No, it's not spam! :-)

I'm just wondering if there is a data type like Money, but with
a (much much much) higher range -- checking the documentation,
it would look like PG uses an int (32bits) to store the amount
of cents -- but -21 million to +21 million is insufficient for
accounting of a small company... :-(

Float is out of the question, of course (if it is really stored
as a float or double).

Any suggestions?

Thanks,

Carlos
--

#2Nils Zonneveld
nils@mbit.nl
In reply to: Carlos Moreno (#1)
Re: I want more Money (the data type, of course! :-))

Carlos Moreno wrote:

No, it's not spam! :-)

I'm just wondering if there is a data type like Money, but with
a (much much much) higher range -- checking the documentation,
it would look like PG uses an int (32bits) to store the amount
of cents -- but -21 million to +21 million is insufficient for
accounting of a small company... :-(

Float is out of the question, of course (if it is really stored
as a float or double).

Any suggestions?

I normally use Numeric(10,2)

HTH,

Nils

#3Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Carlos Moreno (#1)
Re: I want more Money (the data type, of course! :-))

Use numeric with appropriate precision information.

On Sat, 19 May 2001, Carlos Moreno wrote:

Show quoted text

No, it's not spam! :-)

I'm just wondering if there is a data type like Money, but with
a (much much much) higher range -- checking the documentation,
it would look like PG uses an int (32bits) to store the amount
of cents -- but -21 million to +21 million is insufficient for
accounting of a small company... :-(

Float is out of the question, of course (if it is really stored
as a float or double).

#4Dave Cramer
pg@fastcrypt.com
In reply to: Carlos Moreno (#1)
Re: I want more Money (the data type, of course! :-))

Carlos,

We use int8 and keep everything in pennies. Works for us ;)

Dave
----- Original Message -----
From: "Carlos Moreno" <moreno@mochima.com>
To: <pgsql-general@postgresql.org>
Sent: Saturday, May 19, 2001 10:35 AM
Subject: [GENERAL] I want more Money (the data type, of course! :-))

Show quoted text

No, it's not spam! :-)

I'm just wondering if there is a data type like Money, but with
a (much much much) higher range -- checking the documentation,
it would look like PG uses an int (32bits) to store the amount
of cents -- but -21 million to +21 million is insufficient for
accounting of a small company... :-(

Float is out of the question, of course (if it is really stored
as a float or double).

Any suggestions?

Thanks,

Carlos
--

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

#5Carlos Moreno
moreno@mochima.com
In reply to: Stephan Szabo (#3)
Re: I want more Money (the data type, of course! :-))

Stephan Szabo wrote:

Use numeric with appropriate precision information.

I'm assuming that when I use numeric specifying the
number of decimals, there is no rounding error in
the arithmetic and storage? (well, other than
rounding on the decimals beyond the ones specified --
e.g., if I say numeric, 2 decimals, there will be
rounding error only in the 3rd decimal and after
the 3rd decimal?)

If so, then it sounds better than using an 8-byte
integer to keep the pennies, given that it is more
a what-you-get-is-what-you-get thing than storing
the pennies, which is really a what-you-get-is-not-
what-you-get-until-you-divide-it-by-100 ;-)

Thanks!

Carlos
--

#6Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Carlos Moreno (#5)
Re: Re: I want more Money (the data type, of course! :-))

On Thu, 24 May 2001, Carlos Moreno wrote:

Stephan Szabo wrote:

Use numeric with appropriate precision information.

I'm assuming that when I use numeric specifying the
number of decimals, there is no rounding error in
the arithmetic and storage? (well, other than

That's my understanding of it. It's a fixed width
exact value.

#7Carlos Moreno
moreno@mochima.com
In reply to: Stephan Szabo (#6)
Re: Re: I want more Money (the data type, of course! :-))

Stephan Szabo wrote:

I'm assuming that when I use numeric specifying the
number of decimals, there is no rounding error in
the arithmetic and storage? (well, other than

That's my understanding of it. It's a fixed width
exact value.

Sounds great. Thanks to all for the replies!

Cheers,

Carlos
--