16.12.2012 Views

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

min(scale(A) * abs(B), max(scale, scale(A)))<br />

where min calculates the minimum of a set of numbers and max calculates<br />

the maximum.<br />

A * B Calculates A multiplied by B. The scale of the result is:<br />

min(scale(A) + scale(B), max(scale, scale(A), scale(B)))<br />

A / B Calculates A divided by B. The scale of the result is the value of scale.<br />

A % B Calculates the remainder from the division of A by B. This is calculated in<br />

two steps. First, bc calculates A/B to the current scale. It then obtains the<br />

remainder through the formula:<br />

A - (A / B) * B<br />

calculated to the scale:<br />

max(scale + scale(B), scale(A))<br />

A + B Adds A plus B. The scale of the result is the maximum of the two scales of<br />

the operands.<br />

A−B Calculates A minus B. The scale of the result is the maximum of the two<br />

scales of the operands.<br />

The next group of operators are all assignment operators. They assign values to<br />

objects. An assignment operation has a value: the value that is being assigned.<br />

Therefore, you can write such operations as a=1+(b=2). In this operation, the value<br />

of the assignment in parentheses is 2 because that is the value assigned to b.<br />

Therefore, the value 3 is assigned to a. The possible assignment operators are:<br />

V = B Assigns the value of B to V.<br />

V ^= B Is equivalent to V=V^B.<br />

V *= B Is equivalent to V=V*B.<br />

V /= B Is equivalent to V=V/B.<br />

V %= B Is equivalent to V=V%B.<br />

V += B Is equivalent to V=V+B.<br />

V −= B Is equivalent to V=V-B.<br />

The following expressions are called relations, and their values can be either true<br />

(1) or false (0). This version of bc lets you use the relational operators in any<br />

expression, not just in the conditional parts of if, while, or for statements. These<br />

operators work exactly like their equivalents in the C language. The result of a<br />

relation is 0 if the relation is false and 1 if the relation is true.<br />

A == B Is true if and only if A equals B.<br />

A = B Is true if and only if A is greater than or equal to B.<br />

A != B Is true if and only if A is not equal to B.<br />

A < B Is true if and only if A is less than B.<br />

A > B Is true if and only if A is greater than B.<br />

A && B Is true if and only if A is true (nonzero) and B is true. If A is not true,<br />

the expression B is never evaluated.<br />

bc<br />

Chapter 2. Shell command descriptions 55

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!