Numbers

The numeric data types are binary integer, floating-point, and decimal. Binary integer includes small integer and large integer. Floating-point includes single precision and double precision. Binary numbers are exact representations of integers; decimal numbers are exact representations of real numbers; and floating-point numbers are approximations of real numbers.

All numbers have a sign and a precision. When the value of a column or the result of an expression is a decimal or floating-point zero, its sign is positive. The precision of binary integers and decimal numbers is the total number of binary or decimal digits excluding the sign. The precision of floating-point numbers is either single or double, based on the number of hexadecimal digits in the fraction.

The types of numbers are as follows:

Small integer (SMALLINT)
A small integer is a binary integer with a precision of 15 bits. The range of small integers is -32768 to +32767.
Large integer (INTEGER)
A large integer is a binary integer with a precision of 31 bits. The range of large integers is -2147483648 to +2147483647.
Single precision floating-point (REAL or FLOAT)

A single-precision, floating-point number is a 32-bit approximation of a real number. The number can be zero or can range from -3.40282347E+38 to -1.17549435E-38, or from 1.17549435E-38 to 3.40282347E+38.

When the precision of a FLOAT is in the range of 1 to 21, the query processor treats the column as REAL.

The query processor uses standard 370 representation to process single precision floating point numbers. Individual databases might treat these numbers in different representations and support different limits. Likewise, when single precision floating point numbers are manipulated by the CLI, JDBC, and ODBC client components, the representation and limits are based on the platform and compiler that is used.

On the z/OS® server, the 370 representation consists of a sign bit, a 7-bit biased hexadecimal exponent, and a 24-bit fractional part. The exponent bias is 64. All operations on single precision floating point numbers are normalized. The value that can be represented by a single precision floating point number is approximately 6 or 7 decimal digits of precision.

Double precision floating-point (DOUBLE or FLOAT)

A double precision, floating-point number is a 64-bit approximation of a real number. The number can be zero or can range from -1.797693134862315E+308 to -2.225073858507201E-308, or from 2.225073858507201E-308 to 1.797693134862315E+308.

When the precision of a FLOAT is in the range of 22 to 53, the query processor treats the column as DOUBLE PRECISION.

Like single precision numbers, double precision numbers that are manipulated by the z/OS server components use standard 370 representation with the caveat that the source database and client implementation might be different than that used by the data server.

On the z/OS server, the 370 representation consists of a sign bit, a 7-bit biased hexadecimal exponent, and a 56-bit fractional part. The exponent bias is 64. All operations on double precision floating point numbers are normalized. The value that can be represented by a single precision floating point number is approximately 16 or 17 decimal digits of precision.

Decimal (DECIMAL)
A decimal number is a packed decimal number with an implicit decimal point. The position of the decimal point is determined by the precision and the scale of the number. The scale, which is the number of digits in the fractional part of the number, cannot be negative or greater than the precision. The maximum precision is 31 digits.

All values of a decimal column have the same precision and scale. The range of a decimal variable or the numbers in a decimal column is -n to +n, where n is the largest positive number that can be represented with the applicable precision and scale. The maximum range is 1 - 10³¹ to 10³¹ - 1.

String representations of numbers
Values whose data types are small integer, large integer, floating-point, and decimal are stored in an internal form that is transparent to the user of SQL. But string representations of numbers can be used in some contexts. A valid string representation of a number must conform to the rules for numeric constants.