@@ -554,9 +554,9 @@ NUMERIC(<replaceable>precision</replaceable>)
554
554
<programlisting>
555
555
NUMERIC
556
556
</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
560
560
not coerce input values to any particular scale, whereas
561
561
<type>numeric</type> columns with a declared scale will coerce
562
562
input values to that scale. (The <acronym>SQL</acronym> standard
@@ -568,10 +568,10 @@ NUMERIC
568
568
569
569
<note>
570
570
<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"/>.
575
575
</para>
576
576
</note>
577
577
@@ -593,6 +593,11 @@ NUMERIC
593
593
plus three to eight bytes overhead.
594
594
</para>
595
595
596
+ <indexterm>
597
+ <primary>infinity</primary>
598
+ <secondary>numeric (data type)</secondary>
599
+ </indexterm>
600
+
596
601
<indexterm>
597
602
<primary>NaN</primary>
598
603
<see>not a number</see>
@@ -604,13 +609,44 @@ NUMERIC
604
609
</indexterm>
605
610
606
611
<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.)
614
650
</para>
615
651
616
652
<note>
@@ -781,9 +817,14 @@ FROM generate_series(-3.5, 3.5, 1) as x;
781
817
</para>
782
818
</note>
783
819
820
+ <indexterm>
821
+ <primary>infinity</primary>
822
+ <secondary>floating point</secondary>
823
+ </indexterm>
824
+
784
825
<indexterm>
785
826
<primary>not a number</primary>
786
- <secondary>double precision </secondary>
827
+ <secondary>floating point </secondary>
787
828
</indexterm>
788
829
789
830
<para>
@@ -800,11 +841,13 @@ FROM generate_series(-3.5, 3.5, 1) as x;
800
841
as constants in an SQL command, you must put quotes around them,
801
842
for example <literal>UPDATE table SET x = '-Infinity'</literal>. On input,
802
843
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>.
803
846
</para>
804
847
805
848
<note>
806
849
<para>
807
- IEEE754 specifies that <literal>NaN</literal> should not compare equal
850
+ IEEE 754 specifies that <literal>NaN</literal> should not compare equal
808
851
to any other floating-point value (including <literal>NaN</literal>).
809
852
In order to allow floating-point values to be sorted and used
810
853
in tree-based indexes, <productname>PostgreSQL</productname> treats
0 commit comments