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

From: Hannu Krosing <hannu(at)2ndQuadrant(dot)com>
To: Chris Corbyn <chris(at)w3style(dot)co(dot)uk>
Cc: Hannu Krosing <hannu(at)2ndQuadrant(dot)com>, 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 10:34:28
Message-ID: 508D0A34.8060602@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/28/2012 11:05 AM, Chris Corbyn wrote:
> Would this introduce problems finding rows where the stored value is NaN? You'd need to add a function or operator to avoid that.
I guess it should behave similar to NULL-s

That is IS NOT DISTINCT FROM should still return true

test=# select NULL IS NOT DISTINCT FROM NULL as must_be_true;
must_be_true
--------------
t
(1 row)

I guess making the NaN comparison IEEE compliant could introduce
some problems with indexes, so I propose that index operators would
treat NaNs like NULLs

Hannu

> Il giorno 28/ott/2012, alle ore 20:43, Hannu Krosing ha scritto:
>
>> 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.
>>
>> There is some discussion of why it is so at:
>>
>> http://stackoverflow.com/questions/1565164/what-is-the-rationale-for-all-comparisons-returning-false-for-ieee754-nan-values
>>
>> especially the first comment
>>
>> ---------
>> Hannu
>>
>>
>> --
>> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-hackers
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2012-10-28 10:37:41 Re: Should "select 'nan'::float = 'nan'::float;" return false as per IEEE 754
Previous Message Thomas Munro 2012-10-28 10:21:41 Re: Should "select 'nan'::float = 'nan'::float;" return false as per IEEE 754