The following examples illustrate the "Result Decimal Position" precision rules:
*..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
* This example shows the precision of the intermediate values
* using the two precision rules.
D p1 s 26p 2
D p2 s 26p 2
D p3 s 26p 2
D p4 s 26p 9
D s1 s 26s 2
D s2 s 26s 2
D i1 s 10i 0
D f1 s 8f
D proc pr 15p 3
D parm1 20p 5 value
* In the following examples, for each sub-expression,
* two precisions are shown. First, the natural precision,
* and then the adjusted precision.
/FREE
// Example 1:
eval p1 = p1 * p2 * p3;
// p1*p2 -> P(52,4); P(52,4)
// p1*p2*p3 -> P(78,6); P(63,0) (decimal positions are truncated)
eval(r) p1 = p1 * p2 * p3;
// p1*p2 -> P(52,4); P(52,4)
// p1*p2*p3 -> P(78,6); P(63,2) (decimal positions do not drop
// below target decimal positions)
eval(rh)p1 = p1 * p2 * p3;
// p1*p2 -> P(52,4); P(52,5)
// p1*p2*p3 -> P(78,6); P(63,3) (decimal positions do not drop
// below target decimals + 1)
// Example 2:
eval p4 = p1 * p2 * proc (s1*s2*p4);
// p1*p2 -> P(52,4); P(52,4)
// s1*s2 -> P(52,4); P(52,4)
// s1*s2*p4 -> P(78,13); P(63,0) (decimal positions are truncated)
// p1*p2*proc() -> P(67,7); P(63,3) (decimal positions are truncated)
eval(r) p4 = p1 * p2 * proc (s1*s2*p4);
// p1*p2 -> P(52,4); P(52,4)
// s1*s2 -> P(52,4); P(52,4)
// s1*s2*p4 -> P(78,13); P(63,5)
// p1*p2*proc() -> P(67,7); P(63,7) (we keep all decimals since we are
// already below target decimals)
/END-FREE