Re: numeric cast oddity - Mailing list pgsql-general

From Thom Brown
Subject Re: numeric cast oddity
Date
Msg-id bddc86150912030207h6557977anb1cf0a955bde7226@mail.gmail.com
Whole thread Raw
In response to numeric cast oddity  (Sim Zacks <sim@compulab.co.il>)
List pgsql-general
2009/12/3 Sim Zacks <sim@compulab.co.il>
When I cast an integer to numeric using :: notation it ignores the scale
and precision that I specify, but when I use the cast function it uses
the scale and precision that I specify.

Sim

select version();
"PostgreSQL 8.3.5 on i586-pc-linux-gnu, compiled by GCC
i586-pc-linux-gnu-gcc (GCC) 4.1.2 (Gentoo 4.1.2 p1.0.1)"

select -1::numeric(20,4)
?column?
numeric
------------
-1.0000

select cast(-1 as numeric(20,4))
numeric
numeric(20,4)
-------------------
-1.0000


 
That looks right to me.  What you've effectively asked for is -0000000000000001. 0000, which resolves to -1.000.

Regards

Thom

pgsql-general by date:

Previous
From: Sim Zacks
Date:
Subject: numeric cast oddity
Next
From: Thom Brown
Date:
Subject: Re: numeric cast oddity