1XCALC(1) General Commands Manual XCALC(1)
2
3
4
6 xcalc - scientific calculator for X
7
9 xcalc [-stipple] [-rpn] [-toolkitoption...]
10
12 xcalc is a scientific calculator desktop accessory that can emulate a
13 TI-30 or an HP-10C.
14
16 xcalc accepts all of the standard toolkit command line options along
17 with two additional options:
18
19 -stipple
20 This option indicates that the background of the calculator
21 should be drawn using a stipple of the foreground and back‐
22 ground colors. On monochrome displays improves the appearance.
23
24 -rpn This option indicates that Reverse Polish Notation should be
25 used. In this mode the calculator will look and behave like an
26 HP-10C. Without this flag, it will emulate a TI-30.
27
29 Pointer Usage: Operations may be performed with pointer button 1, or in
30 some cases, with the keyboard. Many common calculator operations have
31 keyboard accelerators. To quit, press pointer button 3 on the AC key
32 of the TI calculator, or the ON key of the HP calculator.
33
34 Calculator Key Usage (TI mode): The numbered keys, the +/- key, and the
35 +, -, *, /, and = keys all do exactly what you would expect them to.
36 It should be noted that the operators obey the standard rules of prece‐
37 dence. Thus, entering "3+4*5=" results in "23", not "35". The paren‐
38 theses can be used to override this. For example, "(1+2+3)*(4+5+6)="
39 results in "6*15=90".
40
41 The entire number in the calculator display can be selected, in order
42 to paste the result of a calculation into text.
43
44 The action procedures associated with each function are given below.
45 These are useful if you are interested in defining a custom calculator.
46 The action used for all digit keys is digit(n), where n is the corre‐
47 sponding digit, 0..9.
48
49 1/x Replaces the number in the display with its reciprocal. The
50 corresponding action procedure is reciprocal().
51
52 x^2 Squares the number in the display. The corresponding action
53 procedure is square().
54
55 SQRT Takes the square root of the number in the display. The cor‐
56 responding action procedure is squareRoot().
57
58 CE/C When pressed once, clears the number in the display without
59 clearing the state of the machine. Allows you to re-enter a
60 number if you make a mistake. Pressing it twice clears the
61 state, also. The corresponding action procedure for TI mode
62 is clear().
63
64 AC Clears the display, the state, and the memory. Pressing it
65 with the third pointer button turns off the calculator, in
66 that it exits the program. The action procedure to clear the
67 state is off(); to quit, quit().
68
69 INV Invert function. See the individual function keys for
70 details. The corresponding action procedure is inverse().
71
72 sin Computes the sine of the number in the display, as inter‐
73 preted by the current DRG mode (see DRG, below). If
74 inverted, it computes the arcsine. The corresponding action
75 procedure is sine().
76
77 cos Computes the cosine, or arccosine when inverted. The corre‐
78 sponding action procedure is cosine().
79
80 tan Computes the tangent, or arctangent when inverted. The cor‐
81 responding action procedure is tangent().
82
83 DRG Changes the DRG mode, as indicated by 'DEG', 'RAD', or 'GRAD'
84 at the bottom of the calculator ``liquid crystal'' display.
85 When in 'DEG' mode, numbers in the display are taken as being
86 degrees. In 'RAD' mode, numbers are in radians, and in
87 'GRAD' mode, numbers are in grads. When inverted, the DRG
88 key has a feature of converting degrees to radians to grads
89 and vice-versa. Example: put the calculator into 'DEG'
90 mode, and enter "45 INV DRG". The display should now show
91 something along the lines of ".785398", which is 45 degrees
92 converted to radians. The corresponding action procedure is
93 degree().
94
95 e The constant 'e'. (2.7182818...). The corresponding action
96 procedure is e().
97
98 EE Used for entering exponential numbers. For example, to get
99 "-2.3E-4" you'd enter "2 . 3 +/- EE 4 +/-". The correspond‐
100 ing action procedure is scientific().
101
102 log Calculates the log (base 10) of the number in the display.
103 When inverted, it raises "10.0" to the number in the display.
104 For example, entering "3 INV log" should result in "1000".
105 The corresponding action procedure is logarithm().
106
107 ln Calculates the log (base e) of the number in the display.
108 When inverted, it raises "e" to the number in the display.
109 For example, entering "e ln" should result in "1". The cor‐
110 responding action procedure is naturalLog().
111
112 y^x Raises the number on the left to the power of the number on
113 the right. For example "2 y^x 3 =" results in "8", which is
114 2^3. For a further example, "(1+2+3) y^x (1+2) =" equals "6
115 y^x 3" which equals "216". The corresponding action proce‐
116 dure is power().
117
118 not Performs a bitwise not. The corresponding action procedure
119 is not().
120
121 and Performs a bitwise and. The corresponding action procedure
122 is and().
123
124 or Performs a bitwise or. The corresponding action procedure is
125 or().
126
127 xor Performs a bitwise exclusive or. The corresponding action
128 procedure is xor().
129
130 trunc Truncates the number in the display to an integer. The cor‐
131 responding action procedure is trunc().
132
133 PI The constant 'pi'. (3.1415927....) The corresponding action
134 procedure is pi().
135
136 x! Computes the factorial of the number in the display. The
137 number in the display must be an integer in the range 0-500,
138 though, depending on your math library, it might overflow
139 long before that. The corresponding action procedure is fac‐
140 torial().
141
142 ( Left parenthesis. The corresponding action procedure for TI
143 calculators is leftParen().
144
145 ) Right parenthesis. The corresponding action procedure for TI
146 calculators is rightParen().
147
148 base Changes the number base, as indicated by 'DEC', 'HEX, or
149 'OCT' at the bottom of the calculator display. When in 'DEC'
150 mode, numbers in the display are taken as being decimal (base
151 10). In 'HEX' mode, numbers are in hexadecimal (base 16),
152 and in 'OCT' mode, numbers are in octal (base 8). The corre‐
153 sponding action procedure is base().
154
155 shl Performs an arithmetic bitwise shift left, For example,
156 entering "1 shl 2" should result in "4". The corresponding
157 action procedure is shl().
158
159 shr Performs an arithmetic bitwise shift right, For example,
160 entering "8 shr 1" should result in "4". The corresponding
161 action procedure is shr().
162
163 mod Performs the modulo operation, which calculates the remainder
164 when dividing the first number by the second. For example,
165 entering "14 mod 8" should result in "6". The corresponding
166 action procedure is mod().
167
168 / Division. The corresponding action procedure is divide().
169
170 * Multiplication. The corresponding action procedure is multi‐
171 ply().
172
173 - Subtraction. The corresponding action procedure is sub‐
174 tract().
175
176 + Addition. The corresponding action procedure is add().
177
178 = Perform calculation. The TI-specific action procedure is
179 equal().
180
181 STO Copies the number in the display to the memory location. The
182 corresponding action procedure is store().
183
184 RCL Copies the number from the memory location to the display.
185 The corresponding action procedure is recall().
186
187 SUM Adds the number in the display to the number in the memory
188 location. The corresponding action procedure is sum().
189
190 EXC Swaps the number in the display with the number in the memory
191 location. The corresponding action procedure for the TI cal‐
192 culator is exchange().
193
194 +/- Negate; change sign. The corresponding action procedure is
195 negate().
196
197 . Decimal point. The action procedure is decimal().
198
199
200 Calculator Key Usage (RPN mode): The number keys, CHS (change sign), +,
201 -, *, /, and ENTR keys all do exactly what you would expect them to do.
202 Many of the remaining keys are the same as in TI mode. The differences
203 are detailed below. The action procedure for the ENTR key is enter().
204
205
206 <- This is a backspace key that can be used if you make a mis‐
207 take while entering a number. It will erase digits from the
208 display. (See BUGS). Inverse backspace will clear the X
209 register. The corresponding action procedure is back().
210
211 ON Clears the display, the state, and the memory. Pressing it
212 with the third pointer button turns off the calculator, in
213 that it exits the program. To clear state, the action proce‐
214 dure is off; to quit, quit().
215
216 INV Inverts the meaning of the function keys. This would be the
217 f key on an HP calculator, but xcalc does not display multi‐
218 ple legends on each key. See the individual function keys
219 for details.
220
221 10^x Raises "10.0" to the number in the top of the stack. When
222 inverted, it calculates the log (base 10) of the number in
223 the display. The corresponding action procedure is ten‐
224 power().
225
226 e^x Raises "e" to the number in the top of the stack. When
227 inverted, it calculates the log (base e) of the number in the
228 display. The action procedure is epower().
229
230 STO Copies the number in the top of the stack to a memory loca‐
231 tion. There are 10 memory locations. The desired memory is
232 specified by following this key with a digit key.
233
234 RCL Pushes the number from the specified memory location onto the
235 stack.
236
237 SUM Adds the number on top of the stack to the number in the
238 specified memory location.
239
240 x:y Exchanges the numbers in the top two stack positions, the X
241 and Y registers. The corresponding action procedure is Xex‐
242 changeY().
243
244 R v Rolls the stack downward. When inverted, it rolls the stack
245 upward. The corresponding action procedure is roll().
246
247 blank These keys were used for programming functions on the HP-10C.
248 Their functionality has not been duplicated in xcalc.
249
250 Finally, there are two additional action procedures: bell(), which
251 rings the bell; and selection(), which performs a cut on the entire
252 number in the calculator's ``liquid crystal'' display.
253
255 Accelerators are shortcuts for entering commands. xcalc provides some
256 sample keyboard accelerators; also users can customize accelerators.
257 The numeric keypad accelerators provided by xcalc should be intuitively
258 correct. The accelerators defined by xcalc on the main keyboard are
259 given below:
260
261 TI Key HP Key Keyboard Accelerator TI Function HP Function
262 ─────────────────────────────────────────────────────────────────────
263 SQRT SQRT r squareRoot() squareRoot()
264
265 AC ON space clear() clear()
266 AC <- Delete clear() back()
267 AC <- Backspace clear() back()
268 AC <- Control-H clear() back()
269 AC Clear clear()
270 AC ON q quit() quit()
271 AC ON Control-C quit() quit()
272
273 INV i i inverse() inverse()
274 sin s s sine() sine()
275 cos c c cosine() cosine()
276 tan t t tangent() tangent()
277 DRG DRG d degree() degree()
278
279 e e e()
280 ln ln l naturalLog() naturalLog()
281 y^x y^x ^ power() power()
282
283 PI PI p pi() pi()
284 x! x! ! factorial() factorial()
285 ( ( leftParen()
286 ) ) rightParen()
287
288 / / / divide() divide()
289 * * * multiply() multiply()
290 - - - subtract() subtract()
291 + + + add() add()
292 = = equal()
293
294 0..9 0..9 0..9 digit() digit()
295 +/- CHS n negate() negate()
296
297 x:y x XexchangeY()
298 ENTR Return enter()
299 ENTR Linefeed enter()
300
302 The application class name is XCalc.
303
304 xcalc has an enormous application defaults file which specifies the
305 position, label, and function of each key on the calculator. It also
306 gives translations to serve as keyboard accelerators. Because these
307 resources are not specified in the source code, you can create a cus‐
308 tomized calculator by writing a private application defaults file,
309 using the Athena Command and Form widget resources to specify the size
310 and position of buttons, the label for each button, and the function of
311 each button.
312
313 The foreground and background colors of each calculator key can be
314 individually specified. For the TI calculator, a classical color
315 resource specification might be:
316
317 XCalc.ti.Command.background: gray50
318 XCalc.ti.Command.foreground: white
319
320 For each of buttons 20, 25, 30, 35, and 40, specify:
321 XCalc.ti.button20.background: black
322 XCalc.ti.button20.foreground: white
323
324 For each of buttons 22, 23, 24, 27, 28, 29, 32, 33, 34, 37, 38, and 39:
325 XCalc.ti.button22.background: white
326 XCalc.ti.button22.foreground: black
327
329 In order to specify resources, it is useful to know the hierarchy of
330 the widgets which compose xcalc. In the notation below, indentation
331 indicates hierarchical structure. The widget class name is given
332 first, followed by the widget instance name.
333 XCalc xcalc
334 Form ti or hp (the name depends on the mode)
335 Form bevel
336 Form screen
337 Label M
338 Toggle LCD
339 Label INV
340 Label DEG
341 Label RAD
342 Label GRAD
343 Label P
344 Command button1
345 Command button2
346 Command button3
347 and so on, ...
348 Command button38
349 Command button39
350 Command button40
351
353 rpn (Class Rpn)
354 Specifies that the rpn mode should be used. The default is TI
355 mode.
356
357 stipple (Class Stipple)
358 Indicates that the background should be stippled. The default
359 is ``on'' for monochrome displays, and ``off'' for color dis‐
360 plays.
361
362 cursor (Class Cursor)
363 The name of the symbol used to represent the pointer. The
364 default is ``hand2''.
365
367 If you would like xcalc to use its ti colors, include the following in
368 the #ifdef COLOR section of the file you read with xrdb:
369
370 *customization: -color
371
372 This will cause xcalc to pick up the colors in the app-defaults color
373 customization file: /usr/share/X11/app-defaults/XCalc-color.
374
376 X(7), xrdb(1), the Athena Widget Set
377
379 HP mode is not completely debugged. In particular, the stack is not
380 handled properly after errors.
381
383 Copyright 1994 X Consortium
384 See X(7) for a full statement of rights and permissions.
385
387 John Bradley, University of Pennsylvania
388 Mark Rosenstein, MIT Project Athena
389 Donna Converse, MIT X Consortium
390
391
392
393X Version 11 xcalc 1.1.0 XCALC(1)