Re: Money casting too liberal? - Mailing list pgsql-general

From Michael Nolan
Subject Re: Money casting too liberal?
Date
Msg-id CAOzAquKeu+9MKU+8PXdVTsb258YhiJvPsBKWdJrUc6EreufStw@mail.gmail.com
Whole thread Raw
In response to Money casting too liberal?  (Steve Crawford <scrawford@pinpointresearch.com>)
Responses Re: Money casting too liberal?
List pgsql-general
On 3/27/13, Steve Crawford <scrawford@pinpointresearch.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


pgsql-general by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Money casting too liberal?
Next
From: Misa Simic
Date:
Subject: Re: Is there any way to listen to NOTIFY in php without polling?