MPE/iX Shell and Utilities Reference Manual, Vol 1

bc(1) MPE/iX Shell and Utilities bc(1)
-A is the negation of the expression.
!A is the logical complement of the expression. If A evaluates to zero, !A evalu-
ates to one. If A is not zero, !A evaluates to zero. This operator is unique to
this version of bc.
++V adds 1 to the value of V. The result of the expression is the new value of V.
--V subtracts 1 from the value of V. The result of the expression is the new value of
V.
V++ adds 1 to the value of V, but the result of the expression is the old value of V.
V-- subtracts 1 from the value of V, but the result of the expression is the old value
of V.
AˆB calculates A to the power B. B must be an integer. The scale of the result of
AˆB is
min(scale(A) * abs(B), max(scale, scale(A)))
where min() calculates the minimum of a set of numbers and max() calcu-
lates the maximum.
A*B calculates A multiplied by B. The scale of the result is
min(scale(A) + scale(B), max(scale, scale(A), scale(B)))
A/B calculates A divided by B. The scale of the result is the value of scale.
A%B calculates the remainder from the division of A by B. This is calculated in two
steps. First, bc calculates A/B to the current scale. It then obtains the remain-
der through the formula
A-(A/B)*B
calculated to the scale
max(scale + scale(B), scale(A))
A+B adds A plus B. The scale of the result is the maximum of the two scales of the
operands.
A-B calculates A minus B. The scale of the result is the maximum of the two scales
of the operands.
1-50 Commands and Utilities