On 10/28/2012 11:21 AM, Thomas Munro wrote:
On 28 October 2012 09:43, Hannu Krosing <ha...@2ndquadrant.com> wrote:
This is how PostgreSQL currently works -

test=# select 'NaN'::float = 'NaN'::float as must_be_false;
  must_be_false
----------
  t
(1 row)

I think that PostgreSQL's behaviour of comparing two
NaN-s as equal is wrong and Iwe should follow the IEEE 754 spec here

As per IEEE 754 a NaN behaves similar to NULL in SQL.
FWIW there is a note in the documentation about this:

"Note: IEEE754 specifies that NaN should not compare equal to any
other floating-point value (including NaN). In order to allow
floating-point values to be sorted and used in tree-based indexes,
PostgreSQL treats NaN values as equal, and greater than all non-NaN
values."
I wonder how hard it would be to start treating NaNs as NULLs
so you could say ORDER BY fvalue NULLS AND NANS LAST :)

Hannu




--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to