Numeric type promotion in expressions

In expressions that use only integer types, Derby promotes the type of the result to at least INTEGER. In expressions that mix integer with non-integer types, Derby promotes the result of the expression to the highest type in the expression. The following table shows the promotion of data types in expressions.

Table 1. Type promotion in expressions
Largest Type That Appears in Expression Resulting Type of Expression
DOUBLE PRECISION DOUBLE PRECISION
REAL DOUBLE PRECISION
DECIMAL DECIMAL
BIGINT BIGINT
INTEGER INTEGER
SMALLINT INTEGER
For example:
-- returns a double precision
VALUES 1 + 1.0e0
-- returns a decimal
VALUES 1 + 1.0
-- returns an integer
VALUES CAST (1 AS INT) + CAST (1 AS INT)
Related concepts
Numeric type overview
Related reference
Storing values of one numeric data type in columns of another numeric data type
Scale for decimal arithmetic