Open System Services Shell and Utilities Reference Manual (G06.27+, H06.04+)

bc(1) OSS Shell and Utilities Reference Manual
Enter:
1/6
The system responds as follows:
0.166
You may type the comments (enclosed in /* */), but they are provided only for your
information. The bc command displays the value of each expression when you press
<Return>, except for assignments. Exit by typing quit followed by <return>
2. To convert numbers from one base to another, proceed as follows:
Enter:
bc
obase = 16 /* Display numbers in Hexadecimal */
ibase = 8 /* Input numbers in Octal */
12
The system responds as follows:
A
Enter:
123
The system responds as follows:
53
Enter:
123456
The system responds as follows:
A72E
3. To write and run C-like programs, proceed as follows:
Create the following le prog.bc:
/* compute the factorial of n */
dene f(n) {
auto i, r;
r=1;
for (i=2; i<=n; i++) r =* i;
return (r);
}
Note that the statement following a for or while statement must begin on the same line.
134 Hewlett-Packard Company 527188-004