CALCTOOL(1) — USER COMMANDS
NAME
calctool − a desktop calculator.
SYNOPSIS
calctool [ -a accuracy ] [ -m ] [ -r ] [ -v ]
AVAILABITLIY
This command is available with the OpenWindows environment. For information about installing OpenWindows, refer to the OpenWindows Installation and Start-Up Guide .
DESCRIPTION
Calctool is a desktop calculator. It has been designed to be used with either the mouse or the keyboard. It is visually similar to a lot of hand-held calculators. There are financial, logical and scientific modes. Similar operations are color coded on color workstations. Each key is discussed in more detail below.
Caution: One of the most important things to remember about calctool is that calculations are performed from left to right, with no arithmetic precedence. If you need arithmetic precedence, then you should use parentheses.
Internal arithmetic is done with double precision floating point numbers. Accuracy can be adjusted from zero to nine numeric places in fixed notation, but numbers can be displayed in engineering and scientific notation as well. The calculator reverts to scientific notation when the number is larger than the display would allow in fixed notation. The base of operation can be changed between binary, octal, decimal and hexadecimal. Numbers are initially displayed in fixed notation to two numeric places, in the decimal base.
You can use the Copy(L6) and the Paste(L8) function keys in conjunction with the numeric display to store or retrieve characters from the text shelf. You can also remove the last digit entered, and the whole display can be cleared.
There are ten memory registers. Numbers can be stored or retrieved in these locations, and arithmetic can be performed upon register contents.
The display window contains the current numerical value plus the current base and trigonometric type. There are also indicators that show if the hyperbolic and inverse function switches are set and which numerical mode is currently in operation. If an operation needing more than one numerical input is partially complete, the operation is also displayed in this window as a reminder.
Context sensitive help is also available. Position the cursor over the item you need help with, and press the F1 or Help key. A pop-up will be displayed giving detailed information on this facility.
On startup, calctool will look for a .calctoolrc file in the user’s home directory. This file allows the user to define their own constant and function definitions, plus set up the initial values for the ten memory registers. It then looks for a .calctoolrc file in the current directory, and if present, uses the contents of this file in place of any previously defined values.
With the .calctoolrc file, there are currently four valid record types. These are comments, constant and function definitions, and initial memory register values.
Lines starting with a ’#’ are treated as comments and ignored.
Lines starting with ‘c’ or ‘C’ in the first column are definitions for constants. The character is followed by a digit from 0 through 9 then a space. This is followed by a number in fixed or scientific notation. Following this is an optional comment, which, if found, will be used in the pop-up menu for the constants. If the comment is present, then there must be at least one space between this and the preceding number.
Lines starting with ‘f’ or ‘F’ in the first column are definitions for functions. The character is followed by a digit from 0 through 9 and then a space. This is followed by a function definition. Following this is an optional comment, which, if found, will be used in the pop-up menu for the functions. If the comment is present, then there must be at least one space between this and the preceding function definition.
Lines starting with ‘r’ or ‘R’ in the first column are definitions for the initial contents of the memory registers. The character is followed by a digit from 0 through 9 and then a space. This is followed by a number in fixed or scientific notation. The rest of the line is ignored.
All other lines are ignored. There should be no embedded spaces in the function definitions. Whenever a backslash is found, this and the following character signify a control character, for example \g would be ASCII 7.
OPTIONS
−a accuracy
Initial number of digits displayed after the numeric point. This value must be from 0 through 9. The default is two numeric places.
−m Always display in monochrome, even on a color screen.
−r Start up a "right-handed" version of the calctool program.
−v Print the version number of this release of the calctool program.
CALCULATOR BUTTONS
This section describes the calculator keys present in the main calctool window. Apart from this basic mode, calctool has three other modes, and the keys associated with each of these modes are described in separate sections below.
Keyboard equivalents appear in the square brackets. Note that ‘^’ followed by a letter indicates that the Control key and this key should be pressed together.
Numerical Keys [ 0-9 a-f . = <Return> ].
Enter a digit (decimal digits 0-9 or hexadecimal digits A-F) into the display. The ‘.’ character acts as the numeric point, and ‘=’ (or Return) is used to complete numerical entry.
Up to forty digits may be entered, but internal accuracy will be lost for large numbers.
Arithmetical Operations [ + - x ∗ / ].
Perform an arithmetical operation using the previous entry and the next entry as operands. Addition, subtraction, multiplication and division are denoted by the characters ‘+’, ‘-’, ‘x’ and ‘/’ respectively (‘∗’ is also synonymous with multiplication).
Number Manipulation Operators.
Int[ ^i ]Return the integer portion of the current entry.
Frac[ ^f ]Return the fractional portion of the current entry.
Abs[ ^u ]Return the absolute value of the current entry.
Chs[ C ]Change the arithmetic sign of the current entry.
1/x[ r ]Return the value of 1 divided by the current entry.
x^2[ @ ]Return the square of the current entry.
%[ % ]Perform a percentage calculation using the last entry and the next entry.
Sqrt[ s ]Perform a square root operation on the current entry.
Asc[ ^a ]A separate window is displayed that allows you to enter any character. The ASCII value of this character is then displayed in the current base.
Menu Operations.
Each of these operations has a pop-up menu associated with it. This menu can be displayed using MENU and then you can make a selection. You can select the default item from the menu using SELECT.
It is also possible to use just the keyboard to achieve the same results. The first keyboard value selects the menu operation; the second keyboard character selects the new value for this operation. Unlike the menu facility available with the mouse, there is no visual feedback on what choices are available to you, so the user has to know what item they wish to select.
Base[ B ]Change the base that calculations are displayed in. The available choices are binary
[ b ], octal [ o ], decimal [ d ] and hexadecimal [ h ]. Digits that are inappropriate for a particular base selection are greyed out in the main calctool window.
Disp[ D ]Change the numerical display mode. The choices are engineering [ e ], fixed point
[ f ], and scientific [ s ] notation.
Mode[ M ]Change the calculator mode. By default, calctool is in basic mode, and just the keys on the main calctool window are visible. There are also three other modes; financial [ f ], logical [ l ] and scientific [ s ]. Selection of one of these modes will display an extra window with more keys. These special operations are described in more detail in the sections below.
Acc[ A ]Set the display accuracy. Between 0 and 9 [ 0-9 ] significant digits can be displayed.
Con[ # ]Retrieve and display a constant value. There are ten constant values [ 0-9 ], and each one has a default value which can be overridden by entries in the users .calctoolrc file. The ten default values are: 00.621kms per hour / miles per hour.
11.41421square root of 2.
22.71828e.
33.14159pi.
42.54cms / inch.
557.29578degrees in a radian.
61048576.02 to the power of 20.
70.0353gms / oz.
80.948kilojoules / British thermals.
90.0610cubic cms / cubic inches.
Fun[ F ]Retrieve and execute a function expression. There are ten function definitions [ 0-9 ]. These are set up with entries in the user’s .calctoolrc file.
Rcl[ R ]Retrieve memory register value. There are ten memory registers [ 0-9 ].
Sto[ S ]Store value in memory register. There are ten memory registers [ 0-9 ]. The register number may be preceded by an arithmetic operation (addition, subtraction, multiplication or division), in which case the specified operation is carried out between the displayed entry and the value currently in the selected memory register, and the result is placed in the memory register.
Exch[ X ]Exchange the current display with the contents of a memory register. There are ten memory registers [ 0-9 ].
Other Operations.
Clr[ Delete ]Clear the calculator display.
Bsp[ Back Space ]
Remove the rightmost character of the current entry, and recalculate the displayed value. Note that internal accuracy is lost with this operation.
( and )[ ( and ) ]
Parentheses. Allow precedence with arithmetic calculations. Note that parentheses can be nested to any level, and calctool provides a visual feedback of what is being typed in, in the calculator display. The calculation doesn’t take place until the last parenthesis is matched, then the display is updated with the new result.
Exp[ E ]This is used to allow numbers to be entered in scientific notation. The mantissa should be initially entered, then the Exp key selected. The exponent is then entered. If no numerical input had occurred when the Exp key was selected, then a mantissa of 1.0 is assumed.
Keys[ k ]Toggle the labels on the calctool buttons between the mouse and keyboard equivalents.
Mem[ m ]Display the window with the ten memory register values. These values are displayed in the current base to the current degree of accuracy using the current numerical display notation.
Quit[ q or Q ]Exit without user verification.
FINANCIAL MODE
An example of how to use each of these financial calculations is available via the context sensitive help facility.
Ctrm[ ^t ]Compounding term. Computes the number of compounding periods it will take an investment of present value pv to grow to a future value of fv, earning a fixed interest rate int per compounding period. Memory register usage: Register 0int(periodic interest rate).
Register 1fv(future value).
Register 2pv(present value).
Ddb[ ^d ]Double-declining depreciation. Computes the depreciation allowance on an asset for a specified period of time, using the double-declining balance method. Memory register usage: Register 0cost(amount paid for asset).
Register 1salvage(value of asset at end of life).
Register 2life(useful life of the asset).
Register 3period(time period for depreciation allowance).
Fv[ v ]Future value. This calculation determines the future value of an investment. It computes the future value based on a series of equal payments, each of amount pmt, earning periodic interest rate int, over the number of payment periods in term. Memory register usage: Register 0pmt(periodic payment).
Register 1int(periodic interest rate).
Register 2n(number of periods).
Pmt[ P ]Periodic payment. Computes the amount of the periodic payment of a loan. Most installment loans are computed like ordinary annuities, in that payments are made at the end of each payment period. Memory register usage: Register 0prin(principal).
Register 1int(periodic interest rate).
Register 2n(term).
Pv[ p ]Present value. Determines the present value of an investment. It computes the present value based on a series of equal payments, each of amount pmt, discounted at periodic interest rate int, over the number of periods in term . Memory register usage: Register 0pmt(periodic payment).
Register 1int(periodic interest rate).
Register 2n(term).
Rate[ ^r ]Periodic interest rate. Returns the periodic interest necessary for a present value of pv to grow to a future value of fv over the number of compounding periods in term . Memory register usage: Register 0fv(future value).
Register 1pv(present value).
Register 2n(term).
Sln[ ^s ]Straight-line depreciation. Computes the straight-line depreciation of an asset for one period. The straight-line method of depreciation divides the depreciable cost (cost - salvage) evenly over the useful life of an asset. The useful life is the number of periods typically years) over which an asset is depreciated. Memory register usage: Register 0cost(cost of the asset).
Register 1salvage(salvage value of the asset).
Register 2life(useful life of the asset).
Syd[ ^y ]Sum-of-the years-digits depreciation. The sum-of-the-years’-digits method of depreciation accelerates the rate of depreciation, so that more depreciation expense occurs in earlier periods than in later ones. The depreciable cost is the actual cost minus salvage value. The useful life is the number of periods (typically years) over which an asset is depreciated. Memory register usage: Register 0cost(cost of the asset).
Register 1salvage(salvage value of the asset).
Register 2life(useful life of the asset).
Register 3period(period for which depreciation is computed).
Term[ T ]Payment period. Returns the number of payment periods in the term of an ordinary annuity necessary to accumulate a future value of fv, earning a periodic interest rate of int. Each payment is equal to amount pmt. Memory register usage: Register 0pmt(periodic payment).
Register 1fv(future value).
Register 2int(periodic interest rate).
LOGICAL MODE
<[ < ]Shift the current entry to the left. The shift can be between 1 and 15 places
[ 1-9, a-f ]. This calculator key has a pop-up menu associated with it.
>[ > ]Shift the current entry to the right. The shift can be between 1 and 15 places
[ 1-9, a-f ]. This calculator key has a pop-up menu associated with it.
&16[ ] ]Truncate the current entry to a 16 bit unsigned integer.
&32[ [ ]Truncate the current entry to a 32 bit unsigned integer.
Or[ | ]Perform a logical OR operation on the current entry and the next entry, treating both numbers as unsigned long integers.
And[ & ]Perform a logical AND operation on the current entry and the next entry, treating both numbers as unsigned long integers.
Not[ ~ ]Perform a logical NOT operation on the current entry.
Xor[ ^ ]Perform a logical XOR operation on the current entry and the next entry, treating both numbers as unsigned long integers.
Xnor[ n ]Perform a logical XNOR operation on the current entry and the next entry, treating both numbers as unsigned long integers.
SCIENTIFIC MODE
Trig[ T ]Set the current trigonometrical base. This can be in degrees [ d ], gradients [ g ] or radians [ r ]. This key also has a pop-up menu associated with it.
Hyp[ h ]Toggle the hyperbolic function indicator. This switch affects the type of sine, cosine and tangent trigonometric functions performed.
Inv[ i ]Toggle the inverse function indicator. This switch affects the type of sine, cosine and tangent trigonometric functions performed.
e^x[ { ]Returns e raised to the power of the current entry.
10^x[ } ]Returns 10 raised to the power of the current entry.
y^x[ y ]Take the last entry and raise it to the power of the next entry.
x![ ! ]Return the factorial of the current entry.
Cos[ ^c ]Return the trigonometric cosine, arc cosine, hyperbolic cosine or inverse hyperbolic cosine of the current display, depending upon the current settings of the hyperbolic and inverse function switches. The result is displayed in the current trigonometric units (degrees, radians or gradients).
Sin[ ^s ]Return the trigonometric sine, arc sine, hyperbolic sine or inverse hyperbolic sine of the current display, depending upon the current settings of the hyperbolic and inverse function switches. The result is displayed in the current trigonometric units (degrees, radians or gradients).
Tan[ ^t ]Return the trigonometric tangent, arc tangent, hyperbolic tangent or inverse hyperbolic tangent of the current display, depending upon the current settings of the hyperbolic and inverse function switches. The result is displayed in the current trigonometric units (degrees, radians or gradients).
Ln[ N ]Return the natural logarithm of the current entry.
Log[ G ]Return the base 10 logarithm of the current entry.
Rand[ ? ]Return a random number between 0.0 and 1.0.
FILES
~/.calctoolrc
User’s personal calctool startup file.
SEE ALSO
DeskSet Environment Reference Guide.
Sun Release 4.0 — Last change: 11 June 1990