From: | Magnus Hagander <magnus(at)hagander(dot)net> |
---|---|
To: | vasile <vasile(dot)halosta(at)gmail(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #3475: SQL: 7/2 = 3 |
Date: | 2007-07-20 08:07:43 |
Message-ID: | 20070720080743.GC22622@svr2.hagander.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Fri, Jul 20, 2007 at 07:34:59AM +0000, vasile wrote:
>
> The following bug has been logged online:
>
> Bug reference: 3475
> Logged by: vasile
> Email address: vasile(dot)halosta(at)gmail(dot)com
> PostgreSQL version: 8.2.4
> Operating system: Centos 4.4
> Description: SQL: 7/2 = 3
> Details:
>
> When you divide 2 int the result is also int, is truncated:
>
> On pgsql:
> pg=# select 7/2;
> ?column?
> ----------
> 3
> (1 row)
>
>
> I know in c when you have to int operator the result is also int, but I
> think this is not a good idea in SQL.
That's what you get for integer division. If you want a floating point one,
use:
postgres=> select 7::float/2;
?column?
----------
3.5
(1 row)
//Magnus
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2007-07-20 13:42:03 | WAL replay of truncate fails if the table was dropped |
Previous Message | vasile | 2007-07-20 07:34:59 | BUG #3475: SQL: 7/2 = 3 |