pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14026: Problem to convert number to real
3+ messages / 3 participants
[nested] [flat]

* BUG #14026: Problem to convert number to real
@ 2016-03-16 20:07  carlos_penteado@yahoo.com.br
  0 siblings, 2 replies; 3+ messages in thread

From: carlos_penteado@yahoo.com.br @ 2016-03-16 20:07 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      14026
Logged by:          Carlos
Email address:      carlos_penteado@yahoo.com.br
PostgreSQL version: 9.4.5
Operating system:   windows
Description:        

SELECT 109048.96::float, 0.96::float
RETURNS
109048.96;0.96
but
SELECT 109048.96::real, 0.96::real
RETURNS 
109049;0.96


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #14026: Problem to convert number to real
@ 2016-03-17 23:18  John R Pierce <pierce@hogranch.com>
  parent: carlos_penteado@yahoo.com.br
  1 sibling, 0 replies; 3+ messages in thread

From: John R Pierce @ 2016-03-17 23:18 UTC (permalink / raw)
  To: pgsql-bugs; carlos_penteado@yahoo.com.br

On 3/16/2016 1:07 PM, carlos_penteado@yahoo.com.br wrote:
> SELECT 109048.96::float, 0.96::float
> RETURNS
> 109048.96;0.96
> but
> SELECT 109048.96::real, 0.96::real
> RETURNS
> 109049;0.96


float with unspecified precision is treated as double precision. real is 
by definition single precision, which is only accurate to around 6 digits.

see http://www.postgresql.org/docs/current/static/datatype-numeric.html



-- 
john r pierce, recycling bits in santa cruz



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #14026: Problem to convert number to real
@ 2016-03-17 23:25  Tom Lane <tgl@sss.pgh.pa.us>
  parent: carlos_penteado@yahoo.com.br
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2016-03-17 23:25 UTC (permalink / raw)
  To: carlos_penteado@yahoo.com.br; +Cc: pgsql-bugs

carlos_penteado@yahoo.com.br writes:
> SELECT 109048.96::float, 0.96::float
> RETURNS
> 109048.96;0.96
> but
> SELECT 109048.96::real, 0.96::real
> RETURNS 
> 109049;0.96

"float" means float8, while "real" means float4.  Per
http://www.postgresql.org/docs/9.5/static/datatype-numeric.html#DATATYPE-FLOAT

    PostgreSQL also supports the SQL-standard notations float and float(p)
    for specifying inexact numeric types. Here, p specifies the minimum
    acceptable precision in binary digits. PostgreSQL accepts float(1) to
    float(24) as selecting the real type, while float(25) to float(53)
    select double precision. Values of p outside the allowed range draw an
    error. float with no precision specified is taken to mean double
    precision.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2016-03-17 23:25 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-03-16 20:07 BUG #14026: Problem to convert number to real carlos_penteado@yahoo.com.br
2016-03-17 23:18 ` John R Pierce <pierce@hogranch.com>
2016-03-17 23:25 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox