1- <!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.183 2006/12/22 22:09:31 momjian Exp $ -->
1+ <!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.184 2007/01/14 22:37:59 neilc Exp $ -->
22
33 <chapter id="datatype">
44 <title id="datatype-title">Data Types</title>
438438 <sect2 id="datatype-numeric-decimal">
439439 <title>Arbitrary Precision Numbers</title>
440440
441- <indexterm zone="datatype-numeric-decimal" >
441+ <indexterm>
442442 <primary>numeric (data type)</primary>
443443 </indexterm>
444444
445+ <indexterm>
446+ <primary>arbitrary precision numbers</primary>
447+ </indexterm>
448+
445449 <indexterm>
446450 <primary>decimal</primary>
447451 <see>numeric</see>
@@ -515,6 +519,16 @@ NUMERIC
515519 plus eight bytes overhead.
516520 </para>
517521
522+ <indexterm>
523+ <primary>NaN</primary>
524+ <see>not a number</see>
525+ </indexterm>
526+
527+ <indexterm>
528+ <primary>not a number</primary>
529+ <secondary>numeric (data type)</secondary>
530+ </indexterm>
531+
518532 <para>
519533 In addition to ordinary numeric values, the <type>numeric</type>
520534 type allows the special value <literal>NaN</>, meaning
@@ -525,6 +539,18 @@ NUMERIC
525539 the string <literal>NaN</> is recognized in a case-insensitive manner.
526540 </para>
527541
542+ <note>
543+ <para>
544+ In most implementations of the <quote>not-a-number</> concept,
545+ <literal>NaN</> is not considered equal to any other numeric
546+ value (including <literal>NaN</>). In order to allow
547+ <type>numeric</> values to be sorted and used in tree-based
548+ indexes, <productname>PostgreSQL</> treats <literal>NaN</>
549+ values as equal, and greater than all non-<literal>NaN</>
550+ values.
551+ </para>
552+ </note>
553+
528554 <para>
529555 The types <type>decimal</type> and <type>numeric</type> are
530556 equivalent. Both types are part of the <acronym>SQL</acronym>
@@ -613,6 +639,11 @@ NUMERIC
613639 from zero will cause an underflow error.
614640 </para>
615641
642+ <indexterm>
643+ <primary>not a number</primary>
644+ <secondary>double precision</secondary>
645+ </indexterm>
646+
616647 <para>
617648 In addition to ordinary numeric values, the floating-point types
618649 have several special values:
@@ -631,6 +662,17 @@ NUMERIC
631662 these strings are recognized in a case-insensitive manner.
632663 </para>
633664
665+ <note>
666+ <para>
667+ IEEE754 specifies that <literal>NaN</> should not compare equal
668+ to any other floating-point value (including <literal>NaN</>).
669+ In order to allow floating-point values to be sorted and used
670+ in tree-based indexes, <productname>PostgreSQL</> treats
671+ <literal>NaN</> values as equal, and greater than all
672+ non-<literal>NaN</> values.
673+ </para>
674+ </note>
675+
634676 <para>
635677 <productname>PostgreSQL</productname> also supports the SQL-standard
636678 notations <type>float</type> and