From: | Frank Bax <fbax(at)sympatico(dot)ca> |
---|---|
To: | "sheila timp" <shilet(at)hotmail(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: cast int to float |
Date: | 2002-01-03 18:10:32 |
Message-ID: | 3.0.6.32.20020103131032.01f835c0@pop6.sympatico.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Works for me...
fbax=# create table sheila (item1 int, item2 int, item3 int);
CREATE
fbax=# insert into sheila values (1, 2, 4);
INSERT 5971355 1
fbax=# select ((cast(item1 as float))/(cast(item2 as float) + cast (item3
as float))) as item4 from sheila;
item4
-------------------
0.166666666666667
(1 row)
Perhaps you have a row in your table where item2+item3 = 0?
Frank
At 10:26 PM 12/29/01 +0000, sheila timp wrote:
>Hi,
>
>I'm creating a new database-item by dividing two existing items. When these
>items are initially declared as float, there is no problem. On the other
>hand, when they are declared as int initially and later converted to float,
>I get the error: float8div: divide by zero error. Maybe I didn't do the
>casting right. This is what I did:
>
>((cast(item1 as float))/(cast(item2 as float) + cast (item3 as float))) as
>item4.
>
>I played around with putting the brackets at different places, but every
>time got the same error message.
>Hopefully someone knows what I should do,
>
>Thanks Sheila
>
>_________________________________________________________________
>Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
>subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
>message can get through to the mailing list cleanly
>
From | Date | Subject | |
---|---|---|---|
Next Message | Burra | 2002-01-03 18:28:28 | DATE_ADD, DATE_SUB, ETC |
Previous Message | Frank Bax | 2002-01-03 18:03:58 | Re: dos Dbase -> pg table |