NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
N-13
Considerations—Numeric Data Types
Considerations—Numeric Data Types
All of the preceding data types are exact data types except for the floating point
types, which are approximate data types. Exact data types have greater precision.
Approximate data types are subject to rounding error and should not be used for
equality comparisons or other operations that require exact results.
Floating point (approximate) data types should be used for very large or very small
numbers that cannot be stored in other data types. If you can represent column
values with an exact data type, use the exact data type instead of a floating point
data type.
For more information about numeric data types, see Data Types on page D-1.
Numeric Literals
A numeric literal represents a numeric value. Each numeric literal has the data type
NUMERIC and the minimum precision required to represent the value it specifies.
A simple numeric literal (one without an exponent) can include up to 18 digits (0
through 9), a plus sign (+) or a minus sign (–), and a period (.) that indicates a decimal
point. Leading zeros do not count toward the 18-digit limit; trailing zeros do.
A sign in a simple numeric literal must be the first character of the numeric literal. A
numeric literal without a sign is considered to be a positive number.
A simple numeric literal that does not include a decimal point is considered to be an
integer.
A numeric literal in scientific notation is a simple numeric literal followed by an
exponent expressed as the letter E or e followed by an optionally signed integer.
Numeric values expressed in scientific notation are treated as type REAL if they include
no more than seven digits before the exponent, but treated as type DOUBLE
PRECISION if they include eight or more digits. Because of this, trailing zeros after a
decimal can sometimes increase the precision of a numeric literal used as a DOUBLE
PRECISION value. For example, if XYZ is a table that consists of one DOUBLE
PRECISION column:
INSERT INTO XYZ VALUES (1.00000000E-10);
is more precision than
INSERT INTO XYZ VALUES (1.0E-10);
Examples—Numeric Literals
The following are all numeric literals:
477 580.45 +005 -.3175 1300000000
99. -0.123456789012345678 99E-2