Re: Select (str)::FLOAT8 BUG

From: "Fothergill, Iain" <i(dot)fothergill(at)lancaster(dot)ac(dot)uk>
To: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Select (str)::FLOAT8 BUG
Date: 2004-02-18 15:30:31
Message-ID: E36B692FEB773C4BB3EC8B1828516B87026FCFE4@exchange-be2.lancs.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

My guess would be...

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

Browse pgsql-bugs by date

  From Date Subject
Next Message Rafael Villalobos Prats 2004-02-18 15:37:44 Select (str)::FLOAT8 BUG
Previous Message siva 2004-02-18 10:13:27 i have one doubt