|
|
1.1 root 1: .pa 1
2: .he 'DC (I)'1/15/73'DC (I)'
3: .ti 0
4: NAME dc -- desk calculator
5: .sp
6: .ti 0
7: SYNOPSIS dc__ [file]
8: .sp
9: .ti 0
10: DESCRIPTION dc__
11: is an arbitrary precision integer arithmetic package.
12: The overall structure of dc is
13: a stacking (reverse Polish) calculator.
14: The following constructions are recognized
15: by the calculator:
16: .sp
17: .in +3
18: .ti -3
19: number
20: .br
21: The value of the number is pushed on the stack.
22: A number is an unbroken string of the digits 0-9.
23: It may be preceded by an underscore (_) to input a
24: negative number.
25: .sp
26: .ti -3
27: +_ -_ *_ /_ %_ ^_
28: .br
29: The top two values on the stack are added (+_),
30: subtracted (-_), multiplied (*_), divided (/_),
31: remaindered (%_) or exponentiated (^).
32: The two entries are popped off the stack;
33: the result is pushed on the stack in their place.
34: .sp
35: .ti -3
36: s_x
37: .br
38: The top of the stack is popped and stored into
39: a register named x, where x may be any character.
40: .sp
41: .ti -3
42: l_x
43: .br
44: The value in register x is pushed on the stack.
45: The register x is not altered.
46: All registers start with zero value.
47: .sp
48: .ti -3
49: d_
50: .br
51: The top value on the stack is pushed on the stack.
52: Thus the top value is duplicated.
53: .sp
54: .ti -3
55: p_
56: .br
57: The top value on the stack is printed.
58: The top value remains unchanged.
59: .sp
60: .ti -3
61: f_
62: .br
63: All values on the stack and in registers are printed.
64: .sp
65: .ti -3
66: .ul 1
67: q
68: .br
69: exits the program. If executing a string, the nesting level is
70: popped by two.
71: .sp
72: .ti -3
73: .ul
74: x
75: .br
76: treats the top element of the stack as a character string
77: and executes it as a string of dc commands.
78: .sp
79: .ti -3
80: [...]_____
81: .br
82: puts the bracketed ascii string onto the top of the stack.
83: .sp
84: .ti -3
85: <_x =_x >_x
86: .br
87: The top two elements of the stack are popped and compared.
88: Register x is executed if they obey the stated
89: relation.
90: .sp
91: .ti -3
92: .ul
93: v
94: .br
95: replaces the top element on the stack by its square root.
96: .sp
97: .ti -3
98: !_
99: .br
100: interprets the rest of the line as a UNIX command.
101: .sp
102: .ti -3
103: c_
104: .br
105: All values on the stack are popped.
106: .sp
107: .ti -3
108: i_
109: .br
110: The top value on the stack is popped and used as the
111: number radix for further input.
112: .sp
113: .ti -3
114: o_
115: .br
116: the top value on the stack is popped and used as the
117: number radix for further output.
118: .sp
119: .ti -3
120: z_
121: .br
122: the stack level is pushed onto the stack.
123: .sp
124: .ti -3
125: ?_
126: .br
127: a line of input is taken from the input source (usually the console)
128: and executed.
129: .sp
130: .ti -3
131: new-line
132: .br
133: ignored except as the name of a register or to end the
134: response to a ?_.
135: .sp
136: .ti -3
137: space
138: .br
139: ignored except as the name of a register or to terminate a number.
140: .br
141: .sp
142: .in -3
143: If a file name is given, input is taken from that file until
144: end-of-file, then input is taken from the console.
145: .sp
146: An example to
147: calculate the monthly, weekly and
148: hourly rates for a $10,000/year salary.
149: .sp
150: .nf
151: .in +3
152: 10000
153: 100* (now in cents)
154: dsa (non-destructive store)
155: 12/ (pennies per month)
156: la52/ (pennies per week)
157: d10* (deci-pennies per week)
158: 375/ (pennies per hour)
159: f (print all results)
160: 512
161: 19230
162: 83333
163: "a" 1000000
164: .sp
165: .in -3
166: An example which prints the first ten values of n! is
167: .in +3
168: [la1+dsa*pla10>x]sx
169: 0sa1
170: lxx
171: .sp
172: .fi
173: .in -3
174: .ti 0
175: FILES --
176: .sp
177: .ti 0
178: SEE ALSO msh(VII), salloc(III)
179: .sp
180: .ti 0
181: DIAGNOSTICS (x) ? for unrecognized character x.
182: .br
183: (x) ? for not enough elements on the stack to do what was asked
184: by command x.
185: .br
186: "Out of space" when the free list is exhausted (too many digits).
187: .br
188: "Out of headers" for too many numbers being kept around.
189: .br
190: "Out of pushdown" for too many items on the stack.
191: .br
192: "Nesting Depth" for too many levels of nested execution.
193: .sp
194: .ti 0
195: .ti 0
196: BUGS --
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.