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

From: Hannu Krosing <hannu(at)2ndQuadrant(dot)com>
To: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Should "select 'nan'::float = 'nan'::float;" return false as per IEEE 754
Date: 2012-10-28 09:43:52
Message-ID: 508CFE58.7040708@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chris Corbyn 2012-10-28 10:05:21 Re: Should "select 'nan'::float = 'nan'::float; " return false as per IEEE 754
Previous Message David Lee 2012-10-27 23:20:46 Creating indexes in the background