Re: Should "select 'nan'::float = 'nan'::float;" return false as per IEEE 754

From: Peter Geoghegan <peter(at)2ndquadrant(dot)com>
To: Hannu Krosing <hannu(at)2ndquadrant(dot)com>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Should "select 'nan'::float = 'nan'::float;" return false as per IEEE 754
Date: 2012-10-28 11:36:01
Message-ID: CAEYLb_Wi3X6yKxz34o1=XR3_fu59dZxNf4+_-7bg7PDtCKtqgQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 28 October 2012 09:43, Hannu Krosing <hannu(at)2ndquadrant(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2012-10-28 13:43:07 Re: Logical to physical page mapping
Previous Message Thomas Munro 2012-10-28 10:54:11 Re: Should "select 'nan'::float = 'nan'::float;" return false as per IEEE 754