Re: round() function wrong?

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Michael Brusser <michael(at)synchronicity(dot)com>
Cc: "Jochen Westland [invigo]" <jochen(dot)westland(at)invigo(dot)de>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: round() function wrong?
Date: 2003-10-24 20:50:51
Message-ID: Pine.LNX.4.33.0310241422440.25577-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 numeric
round
-------
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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2003-10-24 21:06:42 Re: Call for port reports
Previous Message Bruce Momjian 2003-10-24 20:49:30 Re: Call for port reports