Re: strange sum behaviour

Поиск
Список
Период
Сортировка
От Andrew Baerg
Тема Re: strange sum behaviour
Дата
Msg-id 2b46a06b0608291156t141b236as1fd33b0f3acbc190@mail.gmail.com
обсуждение исходный текст
Ответ на strange sum behaviour  ("Andrew Baerg" <andrew.baerg@gmail.com>)
Список pgsql-general
Thanks for so many prompt responses. I have researched the differences
between floating point and arbitrary precision numbers in the pgsql
docs and understand now what is happening.

Thanks again to the many great members of the pgsql community.

Andrew

On 8/29/06, Andrew Baerg <andrew.baerg@gmail.com> wrote:
> Hi,
>
> I am getting strange results from the sum function as follows:
>
> corp=# select amount from acc_trans where trans_id=19721 and chart_id=10019;
>  amount
> ---------
>     4.88
>    117.1
>  -121.98
> (3 rows)
>
> corp=# select sum(amount) from acc_trans where trans_id=19721 and
> chart_id=10019;
>          sum
> ----------------------
>  -1.4210854715202e-14
> (1 row)
>
>
> amount is defined as double precision. I noticed that if I cast amount
> as numeric, the sum comes out 0 as expected.
>
> I am using postgresql 8.0.1
>
> Thanks in advance for any help or suggestions.
>
> Andrew Baerg
>

В списке pgsql-general по дате отправления:

Предыдущее
От: garry saddington
Дата:
Сообщение: counting days
Следующее
От: "John D. Burger"
Дата:
Сообщение: Re: strange sum behaviour