4. Understanding the Elements of SQL Statements : SQL Operations : Arithmetic Operations : Arithmetic Operations on Decimal Data Types
 
Share this page                  
Arithmetic Operations on Decimal Data Types
In expressions that combine decimal values and return decimal results, the precision (total number of digits) and scale (number of digits to the right of the decimal point) of the result can be determined, as shown in the following table:
Precision
Scale
Addition and subtraction
Largest number of fractional digits plus largest number of non-fractional digits + 1 (to a maximum of 39)
Scale of operand having the largest scale
Multiplication
Total of precisions to a maximum of 39
Total of scales to a maximum of 39
Division
39
max(39 - p1 + s1 - s2, min(s1, s2));
For example, in the following decimal addition operation:
1.234 + 567.89
the scale and precision of the result is calculated as follows:
Precision = 7
Calculated as 3 (largest number of fractional digits) + 3 (largest number of non-fractional digits) + 1 = 7
Scale = 3
The first operand has the largest number of digits to the right of the decimal point.
Result:
0569.124
If exponentiation is performed on a decimal value, the resulting data type is float.