NAME
xcalc − scientific calculator for X.
SYNTAX
xcalc [options]
DESCRIPTION
xcalc is a scientific calculator desktop accessory that can emulate a TI-30 or an HP-10C. The number in the calculator display can be selected, allowing you to paste the result of a calculation into text. See Chapter 8, Other Clients, for instructions on using the calculator.
Since Release 4, the xcalc buttons have been an oval shape (they are rectangular in earlier versions) and the window is somewhat smaller overall than it was in previous releases. For those of you who like the size of the calculator under R3, try a geometry specification of approximately 167×222 and specify rectangular buttons using the resource setting: xcalc∗shapeStyle: rectangular shapeStyle is a resource of the Athena Command widget. See "Widget Hierarchy" later in this reference page for a diagram of xcalc’s structure and Appendix G for a list of the resources you can set for various widgets.
OPTIONS
xcalc accepts all of the standard X Toolkit command-line options, which are listed on the X reference page. In addition, xcalc accepts the following application-specific options:
-rpnIndicates that Reverse Polish Notation should be used. In this mode, the calculator will look and behave like an HP-10C. Without this flag, it will emulate a TI-30.
-stip, -stipple
Indicates that the background of the calculator should be drawn using a stipple of the foreground and background colors. On monochrome displays, this improves the appearance.
CALCULATOR OPERATIONS
Pointer Usage
Operations may be performed with pointer button 1 (usually the leftmost button), or in many cases, with the keyboard. Many common calculator operations have keyboard equivalents, which are called accelerators, because they facilitate data entry. There are several ways to cause xcalc to exit: pressing the AC key of the TI calculator or the ON key of the HP calculator with pointer button 3 (usually the rightmost button), and typing q, Q, or CTRL-C while the pointer is in the xcalc window.
Calculator Key Usage (TI Mode)
The number keys, the +/− key, and the +, −, ∗, /, and = keys all do exactly what you would expect them to. It should be noted that the operators obey the standard rules of precedence. Thus, entering "3+4∗5=" results in 23, not 35. Parentheses can be used to override this. For example, "(1+2+3)∗(4+5+6)=" is evaluated as "6∗15=" which results in 90.
The action associated with each function is given below. These are useful if you are interested in defining a custom calculator. The action used for all digit keys is digit(n), where n is the corresponding digit, 0-9.
The keys are described below:
1/xReplaces the number in the display with its reciprocal. The corresponding action is reciprocal().
x^2Squares the number in the display. The corresponding action is square().
SQRTEvaluates the square root of the number in the display. The corresponding action is squareRoot().
CE/CWhen pressed once, clears the number in the display without clearing the state of the machine. Allows you to re-enter a number if you make a mistake. Pressing it twice clears the state also. The corresponding action is clear().
ACClears everything: the display, the state, and the memory. Pressing it with the third (usually the right) button "turns off" the calculator, in that it exits the program. The corresponding action to clear the state is off(); to quit, the action is quit().
INVInverts the meaning of the function keys. See the individual function keys for details. The corresponding action is inverse().
sinComputes the sine of the number in the display, as interpreted by the current DRG mode (see DRG, below). If inverted, it computes the arcsine. The corresponding action is sine().
cosComputes the cosine, or arccosine when inverted. The corresponding action is cosine().
tanComputes the tangent, or arctangent when inverted. The corresponding action is tangent().
DRGChanges the DRG mode, as indicated by DEG, RAD, or GRAD at the bottom of the calculator "liquid crystal" display. When in DEG mode, numbers in the display are taken as being degrees. In RAD mode, numbers are in radians, and in GRAD mode, numbers are in gradians. When inverted, the DRG key has the handy feature of converting degrees to radians to gradians and vice versa. For example, put the calculator into DEG mode and type "45 INV DRG". The calculator should display approximately .785398, which is 45 degrees converted to radians. The corresponding action is degree().
eThe constant "e" (2.7182818...). The corresponding action is e().
EEUsed for entering exponential numbers. For example, to enter "-2.3E-4" you would type "2 . 3 +/- EE 4 +/-". The corresponding action is scientific().
logCalculates the log (base 10) of the number in the display. When inverted, it raises 10.0 to the number in the display. For example, entering "3 INV log" should result in 1000. The corresponding action is logarithm().
lnCalculates the log (base e) of the number in the display. When inverted, it raises "e" to the number in the display. For example, entering "e ln" should result in 1. The corresponding action is naturalLog().
y^xRaises the number on the left to the power of the number on the right. For example, "2 y^x 3 =" results in 8, which is 2^3. Also, "(1+2+3) y^x (1+2)=" is evaluated as "6 y^x 3=" which results in 216. The corresponding action is power().
PIThe constant "pi". (3.1415927....) The corresponding action is pi().
x!Computes the factorial of the number in the display. The number in the display must be an integer in the range 0-500, though depending on your math library, it might overflow long before that. The corresponding action is factorial().
(Left parenthesis. The corresponding action for TI calculators is leftParen().
)Right parenthesis. The corresponding action for TI calculators is rightParen().
/Division. The corresponding action is divide().
∗Multiplication. The corresponding action is multiply().
−Subtraction. The corresponding action is subtract().
+Addition. The corresponding action is add().
=Perform calculation. The TI-specific action is equal().
STOCopies the number in the display to the memory location. The corresponding action is store().
RCLCopies the number from the memory location to the display. The corresponding action is recall().
SUMAdds the number in the display to the number in the memory location. The corresponding action is sum().
EXCSwaps the number in the display with the number in the memory location. The corresponding action is exchange().
+/−Negate (change sign). The corresponding action is negate().
.Decimal point. The corresponding action is decimal().
Calculator Key Usage (RPN mode)
The number keys, CHS (change sign), +, −, ∗, /, and ENTR keys all do exactly what you would expect them to. Many of the remaining keys are the same as in TI (default) mode. The differences are detailed below. The action for the ENTR key is enter().
<−Backspace key that can be used while entering a number. It will erase digits from the display. (See "Bugs.") Inverse backspace clears the X register. The corresponding action is back().
ONClears everything: the display, the state, and the memory. Pressing it with the third (usually the right) pointer button "turns off" the calculator, in that it exits the program. The corresponding action to clear the state is off(); to quit, the action is quit().
INVInverts the meaning of the function keys. This would be the "f" key on an HP calculator, but xcalc does not display multiple legends on each key. See the individual function keys for details.
10^xRaises 10.0 to the number in the top of the stack. When inverted, it calculates the log (base 10) of the number in the display. The corresponding action is tenpower().
e^xRaises "e" to the number in the top of the stack. When inverted, it calculates the log (base e) of the number in the display. The corresponding action is epower().
STOCopies the number in the top of the stack to one of ten memory locations. The desired memory is specified by pressing this key and then pressing a digit key.
RCLPushes the number from the specified memory location onto the stack.
SUMAdds the number on top of the stack to the number in the specified memory location.
x:yExchanges the numbers in the top two stack positions, the X and Y registers. The corresponding action is XexchangeY().
R vRolls the stack downward. When inverted, it rolls the stack upward. The corresponding action is roll().
Blank keys were used for programming functions on the HP-10C. Their functionality has not been duplicated in xcalc.
KEYBOARD EQUIVALENTS (ACCELERATORS)
If you have the pointer in the xcalc window, you can use the keyboard to enter numbers and other keys. Almost all of the calculator keys have keyboard equivalents, which are known as accelerators because they speed entry. The number keys, the operator keys, and the parentheses all have the obvious equivalents. The accelerators defined by xcalc are listed in the following table:
| TI Key | HP Key | Keyboard | TI Function | HP Function | ||
| Accelerator | ||||||
| SQRT | SQRT | r | squareRoot() | squareRoot() | ||
| AC | ON | space | clear() | clear() | ||
| AC | <− | Delete | clear() | back() | ||
| AC | <− | Backspace | clear() | back() | ||
| AC | <− | Control-H | clear() | back() | ||
| AC | Clear | clear() | ||||
| AC | ON | q | quit() | quit() | ||
| AC | ON | Control-C | quit() | quit() | ||
| INV | i | i | inverse() | inverse() | ||
| sin | s | s | sine() | sine() | ||
| cos | c | c | cosine() | cosine() | ||
| tan | t | t | tangent() | tangent() | ||
| DRG | DRG | d | degree() | degree() | ||
| e | e | e() | ||||
| ln | ln | l | naturalLog() | naturalLog() | ||
| y^x | y^x | ^ | power() | power() | ||
| PI | PI | p | pi() | pi() | ||
| x! | x! | ! | factorial() | factorial() | ||
| ( | ( | leftParen() | ||||
| ) | ) | rightParen() | ||||
| / | / | / | divide() | divide() | ||
| ∗ | ∗ | ∗ | multiply() | multiply() | ||
| − | − | − | subtract() | subtract() | ||
| + | + | + | add() | add() | ||
| = | = | equal() | ||||
| 0...9 | 0...9 | 0...9 | digit() | digit() | ||
| . | . | . | decimal() | decimal() | ||
| +/- | CHS | n | negate() | negate() | ||
| x:y | x | XexchangeY() | ||||
| ENTR | Return | enter() | ||||
| ENTR | Linefeed | enter() |
RESOURCES
The application class name is XCalc.
xcalc defines the following application resources:
cursor (class Cursor)
The name of the symbol used to represent the pointer. The default is hand2. See Appendix D for a list of cursor names.
rpn (class Rpn)
A Boolean value that specifies whether or not the rpn mode should be used. The default is off—that is, the calculator will be used in TI mode.
stipple (class Stipple)
A Boolean value that indicates whether or not the background should be stippled. The default is on for monochrome displays, and off for color displays.
WIDGET HIERARCHY
In addition, you can specify resources for each of the widgets that make up xcalc. In the notation below, indentation indicates the hierarchical structure of the widgets. The widget class name is given first, followed by the widget instance name. XCalc xcalc Form ti or hp (The name depends on the mode) Form bevel Form screen Label M (The memory indicator on the screen) Toggle LCD (Where the data is displayed) Label INV (The inverted indicator on the display) Label DEG (The degrees indicator on the display) Label RAD (The radians indicator on the display) Label GRAD (The gradians indicator on the display) Label P (The Parenthesis indicator on the display) Command button1 (The actual calculator buttons) Command button2 (Buttons are numbered from right to left) Command button3 (See the app-defaults file for associations and so on...) Command button38 (Between widget names and default labels) Command button39 Command button40 (Only 39 buttons in HP mode) See Appendix G, Athena Widget Resources, for a list of resources that can be set for the Athena widgets.
CUSTOMIZATION
xcalc has an enormous application defaults file, which specifies the position, label, and function of each key on the calculator. It also gives translations to serve as keyboard accelerators. Because these resources are not specified in the source code, you can create a customized calculator by writing a private application defaults file, using the Athena Command and Form widget resources to specify the size and position of buttons, the label for each button, and the function of each button.
The foreground and background colors of each calculator key can be individually specified. For the TI calculator, a classical color resource specification might be: XCalc.ti.Command.background: grey50 XCalc.ti.Command.foreground: white For each of buttons 20, 25, 30, 35, and 40, specify: XCalc.ti.button20.background: black XCalc.ti.button20.foreground: white For each of buttons 22, 23, 24, 27, 28, 29, 32, 33, 34, 37, 38, and 39: XCalc.ti.button22.background: white XCalc.ti.button22.foreground: black
COLORS
As of Release 5, you can opt to use a predefined set of colors for the TI calculator. These colors are provided in a second application defaults file. If you would like your calculator to be viewable in the standard colors, include the following resource definition in your .Xresources file (or whatever file you read with xrdb): ∗customization: -color This will cause xcalc to pick up the colors in the app-defaults color customization file (generally /usr/lib/X11/app-defaults/XCalc-color).
FILES
/usr/lib/X11/app-defaults/XCalc
Specifies required resources.
/usr/lib/X11/app-defaults/XCalc-color
Specifies color resources for the TI calculator (as of Release 5).
SEE ALSO
X, xrdb; Chapter 8, Other Clients; Appendix G, Athena Widget Resources.
BUGS
In HP mode, a bug report claims that the sequence of keys 5, ENTR, and <− should clear the display, but it doesn’t.
AUTHORS
John Bradley, University of Pennsylvania;
Mark Rosenstein, MIT Project Athena.