Re: Money casting too liberal?

From: Michael Nolan <htfoot(at)gmail(dot)com>
To: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Money casting too liberal?
Date: 2013-03-29 19:36:12
Message-ID: CAOzAquKeu+9MKU+8PXdVTsb258YhiJvPsBKWdJrUc6EreufStw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 3/27/13, Steve Crawford <scrawford(at)pinpointresearch(dot)com> wrote:

> Somewhat more worrisome is the fact that it automatically rounds input
> (away from zero) to fit.
>
> select '123.456789'::money;
> money
> ---------
> $123.46

So does casting to an integer:

select 1.25::integer
;
int4
----
1

And then there's this:

create table wkdata
(numval numeric(5,2))

CREATE TABLE
Time: 6.761 ms
nolan=> insert into wkdata
nolan-> values (123.456789);
INSERT 569625265 1
Time: 4.063 ms
nolan=> select * from wkdata;
select * from wkdata;
numval
------
123.46

So rounding a money field doesn't seem inconsistent with other data types.
--
Mike Nolan

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Misa Simic 2013-03-29 20:21:54 Re: Is there any way to listen to NOTIFY in php without polling?
Previous Message Jeff Davis 2013-03-29 19:02:49 Re: Money casting too liberal?