| From: | Magnus Hagander <magnus(at)hagander(dot)net> |
|---|---|
| To: | Renaud Diez <rdiez(at)salesprize(dot)com> |
| Cc: | pgsql-bugs(at)postgresql(dot)org |
| Subject: | Re: BUG #3959: Huge calculation error |
| Date: | 2008-02-13 11:24:13 |
| Message-ID: | 47B2D35D.1000806@hagander.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Renaud Diez wrote:
> The following bug has been logged online:
>
> Bug reference: 3959
> Logged by: Renaud Diez
> Email address: rdiez(at)salesprize(dot)com
> PostgreSQL version: 8.2
> Operating system: Debian
> Description: Huge calculation error
> Details:
>
> the basic mathematical expression like the following one doesn't compute the
> correct result:
>
>> select 100*(1+(21/100));
>
> return a result of 100 instead of 121.
It does compute the correct result, because you're doing integer
calculations. 21/100 for integers is 0. To make it do float calc, you can do
select 100*(1+(21::float/100));
Or you can do
select 100*(1+(21.0/100));
which will force it to numeric.
//Magnus
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Heikki Linnakangas | 2008-02-13 11:24:49 | Re: BUG #3959: Huge calculation error |
| Previous Message | Heikki Linnakangas | 2008-02-13 11:09:45 | Re: BUG #3958: Self-Join Group-By Clause Produces Incorrect Results |