Add a note to the docs describing NaN's equality and ordering behavior.
authorNeil Conway
Sun, 14 Jan 2007 22:37:59 +0000 (22:37 +0000)
committerNeil Conway
Sun, 14 Jan 2007 22:37:59 +0000 (22:37 +0000)
Per recent -hackers thread, this is noteworthy because Postgres behaves
differently from most implementations of NaN, including IEEE754.

doc/src/sgml/datatype.sgml

index 34af82629ed30536215dfacc533ecb427e81ce91..269998a3dde0d771a65330ac94afb8c3aa68d240 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
  
   Data Types
    
     Arbitrary Precision Numbers
 
-     zone="datatype-numeric-decimal">
+    
      numeric (data type)
     
 
+   
+    arbitrary precision numbers
+   
+
     
      decimal
      numeric
@@ -515,6 +519,16 @@ NUMERIC
      plus eight bytes overhead.
     
 
+    
+     NaN
+     not a number
+   
+
+    
+     not a number
+     numeric (data type)
+    
+
     
      In addition to ordinary numeric values, the numeric
      type allows the special value NaN, meaning 
@@ -525,6 +539,18 @@ NUMERIC
      the string NaN is recognized in a case-insensitive manner.
     
 
+    
+     
+      In most implementations of the not-a-number concept,
+      NaN is not considered equal to any other numeric
+      value (including NaN).  In order to allow
+      numeric values to be sorted and used in tree-based
+      indexes, PostgreSQL treats NaN
+      values as equal, and greater than all non-NaN
+      values.
+     
+    
+
     
      The types decimal and numeric are
      equivalent.  Both types are part of the SQL
@@ -613,6 +639,11 @@ NUMERIC
      from zero will cause an underflow error.
     
 
+    
+     not a number
+     double precision
+    
+
     
      In addition to ordinary numeric values, the floating-point types
      have several special values:
@@ -631,6 +662,17 @@ NUMERIC
      these strings are recognized in a case-insensitive manner.
     
 
+    
+     
+      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.
+     
+    
+
     
      PostgreSQL also supports the SQL-standard
      notations float and