Re: Should "select 'nan'::float = 'nan'::float;" return false as per IEEE 754 - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Should "select 'nan'::float = 'nan'::float;" return false as per IEEE 754
Date
Msg-id CAEYLb_Wi3X6yKxz34o1=XR3_fu59dZxNf4+_-7bg7PDtCKtqgQ@mail.gmail.com
Whole thread Raw
In response to Should "select 'nan'::float = 'nan'::float;" return false as per IEEE 754  (Hannu Krosing <hannu@2ndQuadrant.com>)
List pgsql-hackers
On 28 October 2012 09:43, Hannu Krosing <hannu@2ndquadrant.com> wrote:
> 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

The reason that PostgreSQL does this is that in order for float to be
a btree indexable type, its semantics must follow the reflexive law.
This and other requirements of btree operator classes are described
under src/backend/access/nbtree/README.

-- 
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services



pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: Should "select 'nan'::float = 'nan'::float;" return false as per IEEE 754
Next
From: Greg Stark
Date:
Subject: Re: Logical to physical page mapping