@@ -554,9 +554,9 @@ NUMERIC(<replaceable>precision</replaceable>)
554554<programlisting>
555555NUMERIC
556556</programlisting>
557- without any precision or scale creates a column in which numeric
558- values of any precision and scale can be stored, up to the
559- implementation limit on precision . A column of this kind will
557+ without any precision or scale creates an <quote>unconstrained
558+ numeric</quote> column in which numeric values of any length can be
559+ stored, up to the implementation limits . A column of this kind will
560560 not coerce input values to any particular scale, whereas
561561 <type>numeric</type> columns with a declared scale will coerce
562562 input values to that scale. (The <acronym>SQL</acronym> standard
@@ -568,10 +568,10 @@ NUMERIC
568568
569569 <note>
570570 <para>
571- The maximum allowed precision when explicitly specified in the
572- type declaration is 1000; <type>NUMERIC</type> without a specified
573- precision is subject to the limits described in <xref
574- linkend="datatype-numeric-table"/>.
571+ The maximum precision that can be explicitly specified in
572+ a <type>NUMERIC</type> type declaration is 1000. An
573+ unconstrained <type>NUMERIC</type> column is subject to the limits
574+ described in <xref linkend="datatype-numeric-table"/>.
575575 </para>
576576 </note>
577577
@@ -593,6 +593,11 @@ NUMERIC
593593 plus three to eight bytes overhead.
594594 </para>
595595
596+ <indexterm>
597+ <primary>infinity</primary>
598+ <secondary>numeric (data type)</secondary>
599+ </indexterm>
600+
596601 <indexterm>
597602 <primary>NaN</primary>
598603 <see>not a number</see>
@@ -604,13 +609,44 @@ NUMERIC
604609 </indexterm>
605610
606611 <para>
607- In addition to ordinary numeric values, the <type>numeric</type>
608- type allows the special value <literal>NaN</literal>, meaning
609- <quote>not-a-number</quote>. Any operation on <literal>NaN</literal>
610- yields another <literal>NaN</literal>. When writing this value
611- as a constant in an SQL command, you must put quotes around it,
612- for example <literal>UPDATE table SET x = 'NaN'</literal>. On input,
613- the string <literal>NaN</literal> is recognized in a case-insensitive manner.
612+ In addition to ordinary numeric values, the <type>numeric</type> type
613+ has several special values:
614+ <literallayout>
615+ <literal>Infinity</literal>
616+ <literal>-Infinity</literal>
617+ <literal>NaN</literal>
618+ </literallayout>
619+ These are adapted from the IEEE 754 standard, and represent
620+ <quote>infinity</quote>, <quote>negative infinity</quote>, and
621+ <quote>not-a-number</quote>, respectively. When writing these values
622+ as constants in an SQL command, you must put quotes around them,
623+ for example <literal>UPDATE table SET x = '-Infinity'</literal>.
624+ On input, these strings are recognized in a case-insensitive manner.
625+ The infinity values can alternatively be spelled <literal>inf</literal>
626+ and <literal>-inf</literal>.
627+ </para>
628+
629+ <para>
630+ The infinity values behave as per mathematical expectations. For
631+ example, <literal>Infinity</literal> plus any finite value equals
632+ <literal>Infinity</literal>, as does <literal>Infinity</literal>
633+ plus <literal>Infinity</literal>; but <literal>Infinity</literal>
634+ minus <literal>Infinity</literal> yields <literal>NaN</literal> (not a
635+ number), because it has no well-defined interpretation. Note that an
636+ infinity can only be stored in an unconstrained <type>numeric</type>
637+ column, because it notionally exceeds any finite precision limit.
638+ </para>
639+
640+ <para>
641+ The <literal>NaN</literal> (not a number) value is used to represent
642+ undefined calculational results. In general, any operation with
643+ a <literal>NaN</literal> input yields another <literal>NaN</literal>.
644+ The only exception is when the operation's other inputs are such that
645+ the same output would be obtained if the <literal>NaN</literal> were to
646+ be replaced by any finite or infinite numeric value; then, that output
647+ value is used for <literal>NaN</literal> too. (An example of this
648+ principle is that <literal>NaN</literal> raised to the zero power
649+ yields one.)
614650 </para>
615651
616652 <note>
@@ -781,9 +817,14 @@ FROM generate_series(-3.5, 3.5, 1) as x;
781817 </para>
782818 </note>
783819
820+ <indexterm>
821+ <primary>infinity</primary>
822+ <secondary>floating point</secondary>
823+ </indexterm>
824+
784825 <indexterm>
785826 <primary>not a number</primary>
786- <secondary>double precision </secondary>
827+ <secondary>floating point </secondary>
787828 </indexterm>
788829
789830 <para>
@@ -800,11 +841,13 @@ FROM generate_series(-3.5, 3.5, 1) as x;
800841 as constants in an SQL command, you must put quotes around them,
801842 for example <literal>UPDATE table SET x = '-Infinity'</literal>. On input,
802843 these strings are recognized in a case-insensitive manner.
844+ The infinity values can alternatively be spelled <literal>inf</literal>
845+ and <literal>-inf</literal>.
803846 </para>
804847
805848 <note>
806849 <para>
807- IEEE754 specifies that <literal>NaN</literal> should not compare equal
850+ IEEE 754 specifies that <literal>NaN</literal> should not compare equal
808851 to any other floating-point value (including <literal>NaN</literal>).
809852 In order to allow floating-point values to be sorted and used
810853 in tree-based indexes, <productname>PostgreSQL</productname> treats
0 commit comments