Hitachi

Hitachi Advanced Database SQL Reference


7.25.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‒33: Relationship between the data types of the operands and the data type of the result of the operation

No.

Data type of the first operand

Data type of the second operand

Data type of the result of the operation

1

SMALLINT

SMALLINT

INTEGER

2

INTEGER

3

DECIMAL

DECIMAL

4

DOUBLE PRECISION

DOUBLE PRECISION

5

INTEGER

SMALLINT

INTEGER

6

INTEGER

7

DECIMAL

DECIMAL

8

DOUBLE PRECISION

DOUBLE PRECISION

9

DECIMAL

SMALLINT

DECIMAL

10

INTEGER

11

DECIMAL

12

DOUBLE PRECISION

DOUBLE PRECISION

13

DOUBLE PRECISION

SMALLINT

DOUBLE PRECISION

14

INTEGER

15

DECIMAL

16

DOUBLE PRECISION

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), the second operand be DECIMAL(p2,s2), and the result of the operation be DECIMAL(p,s).

If the data type is INTEGER, change the data type to DECIMAL(20,0) during calculation. If the data type is SMALLINT, change the data type to DECIMAL(10,0) during calculation.