Precision when substracting two values with SQL

Поиск
Список
Период
Сортировка
От Juancho
Тема Precision when substracting two values with SQL
Дата
Msg-id 3D58132C.6040303@maxiconsumo.com
обсуждение исходный текст
Ответы Re: Precision when substracting two values with SQL  (Tim Ellis <Tim.Ellis@gamet.com>)
Re: Precision when substracting two values with SQL  (Andrew Sullivan <andrew@libertyrms.info>)
Список pgsql-admin
Hello:
    I have a problem substracting two values whith SQL.  Please
consider this cases...

ciudadela=# select 0.2-0.2;
 ?column?
----------
        0
(1 row)

    That's OK for me,


ciudadela=# select 0.2-0.21;
       ?column?
----------------------
 -0.00999999999999998
(1 row)

    I was hoping -0.01,


ciudadela=# select 0.21-0.22;
 ?column?
----------
    -0.01
(1 row)

    Again, that's OK for me,


    My question is why is this behavior taking place (the second case),
 and how can I avoid it.
    Any suggestion would be really appreciated.
    Thanks,


Juan Manuel
Buenos Aires
Argentina



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

Предыдущее
От: Michael Zouroudis
Дата:
Сообщение: problem with my insert
Следующее
От: Tim Ellis
Дата:
Сообщение: Re: Precision when substracting two values with SQL