Re: Select (str)::FLOAT8 BUG - Mailing list pgsql-bugs

From Fothergill, Iain
Subject Re: Select (str)::FLOAT8 BUG
Date
Msg-id E36B692FEB773C4BB3EC8B1828516B87026FCFE4@exchange-be2.lancs.ac.uk
Whole thread Raw
In response to Select (str)::FLOAT8 BUG  ("Rafael Villalobos Prats" <rvillalobos@asapci.es>)
List pgsql-bugs
My guess would be...=20

1000/5000/7::FLOAT8 is really 1000::INT/500::INT/7::FLOAT8 (int may be some=
 other integer type) whereas (1000/500/7)::FLOAT8 is (1000::INT/500::INT/7:=
:INT)::FLOAT8 i.e. the resultan integer is casted to type FLOAT8 after the =
maths has been done on integers. Thats what I'd expect.


Iain


> -----Original Message-----
> From: pgsql-bugs-owner@postgresql.org
> [mailto:pgsql-bugs-owner@postgresql.org]On Behalf Of Rafael Villalobos
> Prats
> Sent: Wednesday, February 18, 2004 3:38 PM
> To: pgsql-bugs@postgresql.org
> Subject: [BUGS] Select (str)::FLOAT8 BUG
>=20
>=20
> Hi!,
>=20
> I think i have found a bug.
>=20
> I=B4ve tried it in PgSQL 7.3.5 & 7.4.1
>=20
> When I do:
>=20
> atisae_oct_1=3D# SELECT (1000/500/7)::FLOAT8 as v_numero;
>  v_numero
> ----------
>         0
> (1 row)
>=20
> atisae_oct_1=3D# SELECT 1000/500/7::FLOAT8 as v_numero;
>      v_numero
> -------------------
>  0.285714285714286
> (1 row)
>=20
> atisae_oct_1=3D# SELECT (1000/500/7)::NUMERIC as v_numero;
>  v_numero
> ----------
>         0
> (1 row)
>=20
> atisae_oct_1=3D# SELECT 1000/500/7::NUMERIC as v_numero;
>         v_numero
> ------------------------
>  0.28571428571428571429
> (1 row)
>=20
>=20
> Why is different: 'SELECT (xxxxx)::FLOAT8' than 'SELECT xxxxx::FLOAT8'
>=20
> Thanks in advance...
>=20
> Rafa.
>=20
> ---------------------------(end of=20
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>=20
>                http://archives.postgresql.org
>=20

pgsql-bugs by date:

Previous
From: "Rafael Villalobos Prats"
Date:
Subject: Select (str)::FLOAT8 BUG
Next
From: "Rafael Villalobos Prats"
Date:
Subject: Re: Select (str)::FLOAT8 BUG