|
|
1.1 root 1: .th DC I 1/15/73
2: .sh NAME
3: dc \*- desk calculator
4: .sh SYNOPSIS
5: .bd dc
6: [ file ]
7: .sh DESCRIPTION
8: .it Dc
9: is an arbitrary precision integer arithmetic package.
10: The overall structure of
11: .it dc
12: is
13: a stacking (reverse Polish) calculator.
14: The following constructions are recognized
15: by the calculator:
16: .s3
17: .lp +10 10
18: number The value of the number is pushed on the stack.
19: A number is an unbroken string of the digits 0-9.
20: It may be preceded by an underscore \*_ to input a
21: negative number.
22: .s3
23: .lp +10 10
24: +|\*-|*|/|%|^ The top two values on the stack are added
25: (+),
26: subtracted
27: (\*-),
28: multiplied (*),
29: divided (/),
30: remaindered (%),
31: or exponentiated (^).
32: The two entries are popped off the stack;
33: the result is pushed on the stack in their place.
34: .s3
35: .lp +10 10
36: \fBs\fIx\fR The
37: top of the stack is popped and stored into
38: a register named
39: .it x,
40: where
41: .it x
42: may be any character.
43: .s3
44: .lp +10 10
45: \fBl\fIx\fR The
46: value in register
47: .it x
48: is pushed on the stack.
49: The register
50: .it x
51: is not altered.
52: All registers start with zero value.
53: .s3
54: .lp +10 10
55: \fBd\fR The top value on the stack is pushed on the stack.
56: Thus the top value is duplicated.
57: .s3
58: .lp +10 10
59: \fBp\fR The top value on the stack is printed.
60: The top value remains unchanged.
61: .s3
62: .lp +10 10
63: \fBf\fR All values on the stack and in registers are printed.
64: .s3
65: .lp +10 10
66: \fBq\fR exits the program. If executing a string, the nesting level is
67: popped by two.
68: .s3
69: .lp +10 10
70: \fBx\fR treats the top element of the stack as a character string
71: and executes it as a string of dc commands.
72: .s3
73: .lp +10 10
74: \fB[|...|]\fR puts the bracketed ascii string onto the top of the stack.
75: .s3
76: .lp +10 10
77: \fI<x||=x||>x\fR The
78: top two elements of the stack are popped and compared.
79: Register
80: .it x
81: is executed if they obey the stated
82: relation.
83: .s3
84: .lp +10 10
85: \fBv\fR replaces the top element on the stack by its square root.
86: .s3
87: .lp +10 10
88: \fB!\fR interprets the rest of the line as a UNIX command.
89: .s3
90: .lp +10 10
91: \fBc\fR All values on the stack are popped.
92: .s3
93: .lp +10 10
94: \fBi\fR The top value on the stack is popped and used as the
95: number radix for further input.
96: .s3
97: .lp +10 10
98: \fBo\fR The top value on the stack is popped and used as the
99: number radix for further output.
100: .s3
101: .lp +10 10
102: \fBz\fR The stack level is pushed onto the stack.
103: .s3
104: .lp +10 10
105: \fB?\fR A line of input is taken from the input source (usually the console)
106: and executed.
107: .s3
108: .lp +10 10
109: new-line ignored
110: except as the name of a register or to end the
111: response to a
112: .bd ?.
113: .s3
114: .lp +10 10
115: space ignored
116: except as the name of a register or to terminate a number.
117: .s3
118: .i0
119: If a file name is given, input is taken from that file until
120: end-of-file, then input is taken from the console.
121: An example which prints the first ten values of n! is
122: .nf
123: .s3
124: .in +3
125: .bd "[la1+dsa*pla10>x]sx"
126: .bd "0sa1"
127: .bd lxx
128: .s3
129: .fi
130: .in -3
131: .sh FILES
132: /etc/msh to implement `!'
133: .sh DIAGNOSTICS
134: (x) ? for unrecognized character x.
135: .br
136: (x) ? for not enough elements on the stack to do what was asked
137: by command x.
138: .br
139: `Out of space' when the free list is exhausted (too many digits).
140: .br
141: `Out of headers' for too many numbers being kept around.
142: .br
143: `Out of pushdown' for too many items on the stack.
144: .br
145: `Nesting Depth' for too many levels of nested execution.
146: .sh BUGS
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.