Re: Select (str)::FLOAT8 BUG

From: Tarhon-Onu Victor <mituc(at)iasi(dot)rdsnet(dot)ro>
To: Rafael Villalobos Prats <rvillalobos(at)asapci(dot)es>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Select (str)::FLOAT8 BUG
Date: 2004-06-04 05:30:03
Message-ID: Pine.LNX.4.58.0406040824130.27156@blackblue.iasi.rdsnet.ro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, 18 Feb 2004, Rafael Villalobos Prats wrote:

> 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)

This is not a bug and it also has nothing to do with postgresql.
Try the same in C and you will have the same result.
The expression 1000/500/7 contains operations between variables
of an integer type: 1000/500 = 2, 2/7=0. 0::float=0.
Probably a more accurate result will be obtained if you modify
this to:
1000::float/500/7.
In this case 1000/500/7::float or 1000::float/500/7 will return
the same result, but 1000::float/501/7 and 1000/501/7::float will not
because the first operation will be between variables of an integer
type.

--
Tarhon-Onu Victor
Area Technical Coordinator
RDS Iasi - Network Operations Center
www.rdsnet.ro, www.rdstel.ro, www.rdslink.ro
Phone: +40-232-218385; Fax: +40-232-260099
..........................................................................
Privileged/Confidential Information may be contained in this message. If
you are not the addressee indicated in this message (or responsible for
delivery of the message to such person), you may not copy or deliver this
message to anyone. In such a case, you should destroy this message and
kindly notify the sender by reply e-mail.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Pavel Stehule 2004-06-04 12:50:42 is array bug? (array[][])[] = NULL
Previous Message Rob Fielding 2004-06-02 15:37:04 plpython bug in 7.3.x