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

From Thomas Munro
Subject Re: Should "select 'nan'::float = 'nan'::float;" return false as per IEEE 754
Date
Msg-id CADLWmXX9PB18WdYM40E3HjNQDgfF86FPEGv8FfYZBvT7J0p6gQ@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>)
Responses Re: 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:
> 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."



pgsql-hackers by date:

Previous
From: Chris Corbyn
Date:
Subject: Re: Should "select 'nan'::float = 'nan'::float;" return false as per IEEE 754
Next
From: Hannu Krosing
Date:
Subject: Re: Should "select 'nan'::float = 'nan'::float;" return false as per IEEE 754