<entry><type>double precision</type></entry>
<entry>8 bytes</entry>
<entry>variable-precision, inexact</entry>
<entry>15 decimal digits precision</entry>
</row>
<row>
<entry><type>smallserial</type></entry>
<entry>2 bytes</entry>
<entry>small autoincrementing integer</entry>
<entry>1 to 32767</entry>
</row>
<row>
<entry><type>serial</type></entry>
<entry>4 bytes</entry>
<entry>autoincrementing integer</entry>
<entry>1 to 2147483647</entry>
</row>
<row>
<entry><type>bigserial</type></entry>
<entry>8 bytes</entry>
<entry>large autoincrementing integer</entry>
<entry>1 to 9223372036854775807</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
The syntax of constants for the numeric types is described in
<xref linkend="sql-syntax-constants"/>. The numeric types have a
full set of corresponding arithmetic operators and
functions. Refer to <xref linkend="functions"/> for more
information. The following sections describe the types in detail.
</para>
<sect2 id="datatype-int">
<title>Integer Types</title>
<indexterm zone="datatype-int">
<primary>integer</primary>
</indexterm>
<indexterm zone="datatype-int">
<primary>smallint</primary>
</indexterm>
<indexterm zone="datatype-int">
<primary>bigint</primary>
</indexterm>
<indexterm>
<primary>int4</primary>
<see>integer</see>
</indexterm>
<indexterm>
<primary>int2</primary>
<see>smallint</see>
</indexterm>
<indexterm>
<primary>int8</primary>
<see>bigint</see>
</indexterm>
<para>
The types <type>smallint</type>, <type>integer</type>, and
<type>bigint</type> store whole numbers, that is, numbers without
fractional components, of various ranges. Attempts to store
values outside of the allowed range will result in an error.
</para>
<para>
The type <type>integer</type> is the common choice, as it offers
the best balance between range, storage size, and performance.
The <type>smallint</type> type is generally only used if disk
space is at a premium. The <type>bigint</type> type is designed to be
used when the range of the <type>integer</type> type is insufficient.
</para>
<para>
<acronym>SQL</acronym> only specifies the integer types
<type>integer</type> (or <type>int</type>),
<type>smallint</type>, and <type>bigint</type>. The
type names <type>int2</type>, <type>int4</type>, and
<type>int8</type> are extensions, which are also used by some
other <acronym>SQL</acronym> database systems.
</para>
</sect2>
<sect2 id="datatype-numeric-decimal">
<title>Arbitrary Precision Numbers</title>
<indexterm>
<primary>numeric (data type)</primary>
</indexterm>
<indexterm>
<primary>arbitrary precision numbers</primary>
</indexterm>
<indexterm>
<primary>decimal</primary>
<see>numeric</see>
</indexterm>
<para>
The type <type>numeric</type> can store numbers with a
very large number of digits. It is especially recommended for
storing monetary amounts and other quantities where exactness is
required. Calculations with <type>numeric</type> values yield exact
results where possible, e.g., addition, subtraction, multiplication.
However, calculations on <type>numeric</type> values are very slow
compared to the integer types, or to the floating-point types
described in the next section.
</para>
<para>
We use the following terms below: The
<firstterm>precision</firstterm> of a <type>numeric</type>
is the total count of significant digits in the whole number,
that is, the number of digits to both sides of the decimal point.
The <firstterm>scale</firstterm> of a <type>numeric</type>