Re: BUG #3791: Bug in aritmethic calculations

From: "Gevik Babakhani" <pgdev(at)xs4all(dot)nl>
To: "'Michailas'" <michailas(dot)p(at)gmail(dot)com>, <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #3791: Bug in aritmethic calculations
Date: 2007-11-30 10:00:16
Message-ID: 000001c83337$cf07ec80$0a01a8c0@gevmus
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I think this is not a bug.
abs(300 - 200)/200 is calculated as integer.
try:

gevik=# SELECT abs(300 - 200)/200::float*100 as bad, abs(300-200)*100/200 as
good;
bad | good
-----+------
50 | 50
(1 row)

------------------------------------------------
Gevik Babakhani

PostgreSQL NL http://www.postgresql.nl
TrueSoftware BV http://www.truesoftware.nl
------------------------------------------------

> -----Original Message-----
> From: pgsql-bugs-owner(at)postgresql(dot)org
> [mailto:pgsql-bugs-owner(at)postgresql(dot)org] On Behalf Of Michailas
> Sent: Friday, November 30, 2007 10:18 AM
> To: pgsql-bugs(at)postgresql(dot)org
> Subject: [BUGS] BUG #3791: Bug in aritmethic calculations
>
>
> The following bug has been logged online:
>
> Bug reference: 3791
> Logged by: Michailas
> Email address: michailas(dot)p(at)gmail(dot)com
> PostgreSQL version: 8.2.4-2
> Operating system: Debian
> Description: Bug in aritmethic calculations
> Details:
>
> postgres=# SELECT abs(300 - 200)/200*100 as bad,
> abs(300-200)*100/200 as good;
>
> bad | good
> -----+------
> 0 | 50
> (1 row)
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Gregory Stark 2007-11-30 10:11:57 Re: BUG #3791: Bug in aritmethic calculations
Previous Message Marek 2007-11-30 10:00:03 BUG #3792: cluster in UTF deny database in LATIN2