numeric and float comparison oddities

Поиск
Список
Период
Сортировка
От Jeff Davis
Тема numeric and float comparison oddities
Дата
Msg-id 1406874824.15301.47.camel@jeff-desktop
обсуждение исходный текст
Ответы Re: numeric and float comparison oddities
Список pgsql-hackers
I saw some strange results:

postgres=# select '1.1'::numeric = '1.1'::float8;?column? 
----------t
(1 row)

postgres=# select '1.1'::numeric = '1.1'::float4;?column? 
----------f
(1 row)

When I looked into it, I saw that the numeric is being cast to a float8,
making the first statement trivially true. 

Why does the cast go from numeric to float if that direction loses
precision? One reason is because float supports +/- infinity, but that
seems more like convenience than a good reason. Is there another reason?

Have we considered adding +/- infinity to numeric so that it can
represent every float value? That might make the numeric hierarchy a
little cleaner and less surprising.

Regards,Jeff Davis





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

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: Proposal: Incremental Backup
Следующее
От: Fabien COELHO
Дата:
Сообщение: Re: gaussian distribution pgbench -- splits v4