HP 3000 Manuals

Decimal Operations [ ALLBASE/SQL Reference Manual ] MPE/iX 5.5 Documentation


ALLBASE/SQL Reference Manual

Decimal Operations 

The precision (p) and scale (s) of a DECIMAL result depend on the
operation used to derive it.  The following rules define the precision
and scale that result from arithmetic operations on two decimal values
having precisions p1 and p2 and respective scales s1 and s2.  Rules are
also provided for the resulting precision and scale of aggregate
functions that operate on a single expression having a precision of p1 
and a scale of s1.  Arithmetic operations and aggregate functions are
discussed further in the "Expressions" chapter.[REV BEG]

Addition and Subtraction 

p = MIN(27, MAX (p1 - s1 , p2 - s2) + MAX(s1, s2)+ 1)

s = MAX (s1,s2)

Multiplication 

p = MIN (27, p1 + p2)

s = MIN (27, s1 + s2)

Division 

p = 27

s = 27 - MIN (27, p1 - s1 + s2)

where p1 and s1 describe the numerator operand, and p2 and s2 describe
the denominator operand.

MAX and MIN Functions 

p = p1 

s = s1 

SUM Function 

p = 27

s = s1 

AVG Function 

p = 27

s = 27 - p1 + s1[REV END]



MPE/iX 5.5 Documentation