Hitachi

Hitachi Advanced Database SQL Reference


7.26.2 Data types of the results of arithmetic operations

The data type of the result of an arithmetic operation is determined by the data types of the first and second operands. The following table shows the relationship between the data types of the operands and the data type of the result of the operation.

Table 7‒45: Relationship between the data types of the operands and the data type of the result of the operation

Data type of the first operand

Data type of the second operand

Data type of the result of the operation

BIGINT,

INTEGER,

SMALLINT

BIGINT

BIGINT#

INTEGER

SMALLINT

DECIMAL

DECIMAL

NUMERIC

DOUBLE PRECISION

DOUBLE PRECISION

FLOAT

REAL

DECIMAL,

NUMERIC

BIGINT

DECIMAL

INTEGER

SMALLINT

DECIMAL

NUMERIC

DOUBLE PRECISION

DOUBLE PRECISION

FLOAT

REAL

DOUBLE PRECISION,

FLOAT,

REAL

BIGINT

DOUBLE PRECISION

INTEGER

SMALLINT

DECIMAL

NUMERIC

DOUBLE PRECISION

FLOAT

REAL

#

If the integer data type format is a legacy format, it will be an INTEGER type.

If the data type of the result of the operation is DECIMAL, the precision and scaling will be as follows:

Let the first operand be DECIMAL(p1,s1) or NUMERIC(p1,s1), the second operand be DECIMAL(p2,s2) or NUMERIC(p2,s2), and the result of the operation be DECIMAL(p,s).

If the data type of the result of the operation is BIGINT, calculate as DECIMAL(20,0); if it is INTEGER, calculate as DECIMAL(10,0); if it is SMALLINT, calculate as DECIMAL(5,0).#

#

If the integer data type format is in a legacy format, calculate as DECIMAL(20,0) when the data type of the result of the operation is BIGINT or INTEGER type, or DECIMAL(10,0) when the data type is SMALLINT type.