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.

Options<br />

Numbers<br />

Identifiers<br />

bc supports the following options.<br />

–i Puts bc into interactive mode with a displayed prompt. In this mode, bc<br />

displays a prompt, which is “:”—waiting for input. In addition, it handles<br />

errors somewhat differently. Normally, when bc encounters an error while<br />

processing a file, the interpreter displays the error message and exits. In<br />

interactive mode, the interpreter displays the message and returns to the<br />

prompt mode to allow debugging.<br />

–l Loads a library of standard mathematical functions before processing any<br />

other input. This library also sets the scale to 20. For a description of the<br />

functions in the –l library, see Built-in Functions.<br />

Numbers consist of an optional minus (−) sign or an optional plus (+) sign followed<br />

by a sequence of zero or more digits, followed by an optional decimal point (.),<br />

followed by a sequence of zero or more digits. Valid digits are 0 through 9, and the<br />

hexadecimal digits A through F. The uppercase letters represent the values from 10<br />

through 15. There must be at least one digit, either before or after the decimal point.<br />

If not, bc interprets the decimal point as the special variable ..<br />

A number can be arbitrarily long and can contain spaces. Here are some valid<br />

numbers with an input base of 10:<br />

0 0. .0 -3.14159 +09. -12 1 000 000<br />

Here are some valid numbers with an input base of 16 (ibase=16):<br />

0 FF FF.3 -10.444 A1<br />

See Bases for more information.<br />

A final point is that you cannot break up numbers with commas; you can write<br />

1000000 or 1 000 000, but 1,000,000 results in an error message.<br />

Identifiers can include sequences containing any number of letters, digits, or the<br />

underscore (_) character but must start with a lowercase letter. Spaces are not<br />

allowed in identifiers.<br />

In the P<strong>OS</strong>IX locale, valid identifiers can include sequences containing any number<br />

of letters, digits, or the underscore (_) character but must start with a lowercase<br />

letter, as defined by the current locale.<br />

For other locales, the character map for that locale determines which characters are<br />

valid in an identifier. If you want identifiers to be portable between locales, use<br />

characters from the P<strong>OS</strong>IX character set. The use of identifiers longer than one<br />

character is an extension of this implementation. Identifiers are used as names for<br />

variables, functions, or arrays:<br />

v A variable holds a single numeric value. You can declare variables that are local<br />

to a function using the auto statement. (See Functions). All other variables are<br />

global and you can use them inside any function or outside all functions. You do<br />

not need to declare global variables. bc creates variables as it requires them,<br />

with an initial value of zero. (Remember that there is also the special variable .<br />

[dot], which contains the result of the last calculation.)<br />

bc<br />

Chapter 2. Shell command descriptions 51

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

Saved successfully!

Ooh no, something went wrong!