The result data type for binary arithmetic operations involving DECIMAL operands is as follows:
Left Operand | Right Operand | Operator | Result Data Type |
---|---|---|---|
DATE | DECIMAL(k,j) | * / MOD | DECIMAL(p,j) These operations on DATE do not report an error, but results are rarely meaningful. |
BYTEINT SMALLINT INTEGER BIGINT |
* / + - MOD | DECIMAL(p,j) | |
DECIMAL(m,n) | BYTEINT SMALLINT INTEGER BIGINT |
+ - * | DECIMAL(p,n) |
DATE | * | DECIMAL(p,n) These operations on DATE do not report an error, but results are rarely meaningful. |
In these cases, the value of p, the number of digits in the decimal result, depends on:
- The number of digits in the decimal operand, where the number of digits is k for a DECIMAL(k,j) operand on the right side of the operator or m for a DECIMAL(m,n) operand on the left side of the operator.
Left Operand | Right Operand | Operator | Result Data Type |
---|---|---|---|
DECIMAL(m,n) | DECIMAL(k,j) | + - | DECIMAL(min(p, (1+max(n,j)+max(m -n,k -j))),max(n,j)) |
* | DECIMAL(min(p,m +k),(n +j)) | ||
/ MOD | DECIMAL(p,max(n,j)) |