Re: round() function wrong? - Mailing list pgsql-hackers

From scott.marlowe
Subject Re: round() function wrong?
Date
Msg-id Pine.LNX.4.33.0310241422440.25577-100000@css120.ihs.com
Whole thread Raw
In response to Re: round() function wrong?  (Michael Brusser <michael@synchronicity.com>)
Responses Re: round() function wrong?
List pgsql-hackers
On Fri, 24 Oct 2003, Michael Brusser wrote:

> But this seems to work correctly on 7.3.2 and 7.3.4:
> psql -c "select round (2.5)"
> Password: 
>  round 
> -------
>      3
> (1 row)
> 
> =============
> > 
> > I just tried that on my 7.2.4 and 7.4 beta 4 machines and I get 2 for 
> > round(2.5)

Ackkk.  I accidentally tested it on my 7.3.4 box, not my 7.4 beta 4 box. 
but the output is the same.  The original, I believe, had '' marks in it.

Anyway, it seems to matter about the ''s in 7.3.x:


In pgsql 7.2:

select round(2.5::float);round
-------    2
(1 row)

select round(2.5::numeric);round
-------    3
(1 row)

select round(2.5);  <-- would appear to be coerced to float here)round
-------    2
(1 row)

select round('2.5');
ERROR:  Function 'round(unknown)' does not exist       Unable to identify a function that satisfies the given argument

types       You may need to add explicit typecasts


pgsql 7.3.4:


select round(2.5::float);round
-------    2
(1 row)

select round(2.5::numeric);round
-------    3
(1 row)

select round(2.5);  <-- would appear to be coerced to numericround
-------    3
(1 row)

select round('2.5');round
-------    2
(1 row)

pgsql 7.4 beta5: behaves the same as 7.3.4

So it would appear to be that the automatic assumptions about what is 
float and what is numeric changed from 7.2 to 7.3, i.e. it's assumed that 
numeric is the input type.

But I'm just guessing here.





pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Call for port reports
Next
From: Peter Eisentraut
Date:
Subject: Re: Call for port reports