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

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

From
Carlos Moreno
Date:
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
--

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

From
Nils Zonneveld
Date:

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

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

From
Stephan Szabo
Date:
Use numeric with appropriate precision information.

On Sat, 19 May 2001, 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).


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

From
"Dave Cramer"
Date:
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! :-))


>
> 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
>


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

From
Carlos Moreno
Date:
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
--

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

From
Stephan Szabo
Date:
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.


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

From
Carlos Moreno
Date:
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
--