Re: Bug #644: Incorrect result in math operation

Поиск
Список
Период
Сортировка
От Dmitry Tsitelov
Тема Re: Bug #644: Incorrect result in math operation
Дата
Msg-id 20020424131725.1fecf713.cit@tag-ltd.spb.ru
обсуждение исходный текст
Ответ на Bug #644: Incorrect result in math operation  (pgsql-bugs@postgresql.org)
Список pgsql-bugs
Hi!

On Wed, 24 Apr 2002 04:33:00 -0400 (EDT)
pgsql-bugs@postgresql.org wrote:

> Francisco Blay (franblay@ono.com) reports a bug with a severity of 3
> The lower the number the more severe it is.
>
> Short Description
> Incorrect result in math operation
>
> Long Description
> 3088.8 - (2847.64 + 241.16)=4.54747350886464e-13
> It's spected to be 0.0 the result of this operation (I think)
> Got the same results in
>
...
> datadb=# select 3088.8 - (2847.64 + 241.16) AS silly;
>         silly
> ----------------------
>  4.54747350886464e-13
> (1 row)
>

I think it's a limitation of floating point numbers representation, not a PostgreSQL bug. Use NUMERIC type, if you need
an"exact" precision: 

org=> SELECT 3088.8::numeric(8,3) - (2847.64::numeric(8,3) + 241.16::numeric(8,3)) AS silly;
 silly
-------
 0.000
(1 row)

Best regards

--
Dmitry Tsitelov
mailto:cit@tag-ltd.spb.ru

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

Предыдущее
От: pgsql-bugs@postgresql.org
Дата:
Сообщение: Bug #644: Incorrect result in math operation
Следующее
От: Hubert depesz Lubaczewski
Дата:
Сообщение: problems with non-trust authentication methods in 7.3devel?