Re: convert real to numeric.

2018-10-20 Thread Peter J. Holzer
On 2018-10-18 18:58:13 -0400, Tom Lane wrote: > "Peter J. Holzer" writes: > > On 2018-10-18 10:15:40 -0400, Tom Lane wrote: > >> You could ju-jitsu the system into duplicating that behavior by casting > >> to text (which invokes float4out) and then to numeric: > > > I suggest casting first to flo

Re: convert real to numeric.

2018-10-18 Thread Tom Lane
"Peter J. Holzer" writes: > On 2018-10-18 10:15:40 -0400, Tom Lane wrote: >> You could ju-jitsu the system into duplicating that behavior by casting >> to text (which invokes float4out) and then to numeric: > I suggest casting first to float8 and then to numeric. The conversion > from float4 to f

Re: convert real to numeric.

2018-10-18 Thread Peter J. Holzer
On 2018-10-18 10:15:40 -0400, Tom Lane wrote: > Alessandro Aste writes: > > I need to convert an SQL field from real to numeric, but I’m getting a > > strange behavior. > > select amount, amount::numeric, amount::numeric(16,4), > > amount::varchar::numeric from mytable where id = 32560545; > > Res

Re: convert real to numeric.

2018-10-18 Thread Tom Lane
Alessandro Aste writes: > I need to convert an SQL field from real to numeric, but I’m getting a > strange behavior. > select amount, amount::numeric, amount::numeric(16,4), > amount::varchar::numeric from mytable where id = 32560545; > Result: > 17637.75, 17637.8, 17637.8000, 17637.75 You realiz

Re: convert real to numeric.

2018-10-18 Thread Adrian Klaver
On 10/18/18 3:28 AM, Alessandro Aste wrote: Hi, Postresql version: 10.5 I need to convert an SQL field from real to numeric, but I’m getting a strange behavior. See the following query in preprod: select amount, amount::numeric, amount::numeric(16,4), amount::varchar::numeric from mytabl

convert real to numeric.

2018-10-18 Thread Alessandro Aste
Hi, Postresql version: 10.5 I need to convert an SQL field from real to numeric, but I’m getting a strange behavior. See the following query in preprod: select amount, amount::numeric, amount::numeric(16,4), amount::varchar::numeric from mytable where id = 32560545; Result: 17637.75