Go to the previous, next section.

"Keypad" Mode

The M-# k (calc-keypad) command starts the Calculator and displays a picture of a calculator-style keypad. If you are using the X window system, you can click on any of the "keys" in the keypad using the left mouse button to operate the calculator. The original window remains the selected window; in keypad mode you can type in your file while simultaneously performing calculations with the mouse.

If you have used M-# b first, M-# k instead invokes the full-calc-keypad command, which takes over the whole Emacs screen and displays the keypad, the Calc stack, and the Calc trail all at once. This mode would normally be used when running Calc standalone (see section Standalone Operation).

If you aren't using the X window system, you must switch into the `*Calc Keypad*' window, place the cursor on the desired "key," and type SPC or RET. If you think this is easier than using Calc normally, go right ahead.

Calc commands are more or less the same in keypad mode. Certain keypad keys differ slightly from the corresponding normal Calc keystrokes; all such deviations are described below.

Keypad Mode includes many more commands than will fit on the keypad at once. Click the right mouse button [calc-keypad-menu] to switch to the next menu. The bottom five rows of the keypad stay the same; the top three rows change to a new set of commands. To return to earlier menus, click the middle mouse button [calc-keypad-menu-back] or simply advance through the menus until you wrap around. Typing TAB inside the keypad window is equivalent to clicking the right mouse button there.

You can always click the EXEC button and type any normal Calc key sequence. This is equivalent to switching into the Calc buffer, typing the keys, then switching back to your original buffer.

Main Menu

|----+-----Calc 2.00-----+----1
| LN |EXP |    |ABS |IDIV|MOD |
|SIN |COS |TAN |SQRT|y^x |1/x |
|  ENTER  |+/- |EEX |UNDO| <- |
| INV |  7  |  8  |  9  |  /  |
| HYP |  4  |  5  |  6  |  *  |
|EXEC |  1  |  2  |  3  |  -  |
| OFF |  0  |  .  | PI  |  +  |

This is the menu that appears the first time you start Keypad Mode. It will show up in a vertical window on the right side of your screen. Above this menu is the traditional Calc stack display. On a 24-line screen you will be able to see the top three stack entries.

The ten digit keys, decimal point, and EEX key are used for entering numbers in the obvious way. EEX begins entry of an exponent in scientific notation. Just as with regular Calc, the number is pushed onto the stack as soon as you press ENTER or any other function key.

The +/- key corresponds to normal Calc's n key. During numeric entry it changes the sign of the number or of the exponent. At other times it changes the sign of the number on the top of the stack.

The INV and HYP keys modify other keys. As well as having the effects described elsewhere in this manual, Keypad Mode defines several other "inverse" operations. These are described below and in the following sections.

The ENTER key finishes the current numeric entry, or otherwise duplicates the top entry on the stack.

The UNDO key undoes the most recent Calc operation. INV UNDO is the "redo" command, and HYP UNDO is "last arguments" (M-RET).

The <- key acts as a "backspace" during numeric entry. At other times it removes the top stack entry. INV <- clears the entire stack. HYP <- takes an integer from the stack, then removes that many additional stack elements.

The EXEC key prompts you to enter any keystroke sequence that would normally work in Calc mode. This can include a numeric prefix if you wish. It is also possible simply to switch into the Calc window and type commands in it; there is nothing "magic" about this window when Keypad Mode is active.

The other keys in this display perform their obvious calculator functions. CLN2 rounds the top-of-stack by temporarily reducing the precision by 2 digits. FLT converts an integer or fraction on the top of the stack to floating-point.

The INV and HYP keys combined with several of these keys give you access to some common functions even if the appropriate menu is not displayed. Obviously you don't need to learn these keys unless you find yourself wasting time switching among the menus.

INV +/-
is the same as 1/x.
is the same as SQRT.
is the same as CONJ.
is the same as y^x.
is the same as INV y^x (the xth root of y).
are the same as SIN / INV SIN.
are the same as COS / INV COS.
are the same as TAN / INV TAN.
are the same as LN / HYP LN.
are the same as EXP / HYP EXP.
is the same as ABS.
is the same as RND (calc-round).
is the same as CLN2.
is the same as FLT (calc-float).
is the same as IMAG.
is the same as PREC.
is the same as SWAP.
is the same as RLL3.
is the same as OVER.
HYP +/-
packs the top two stack entries as an error form.
packs the top two stack entries as a modulo form.
creates an interval form; this removes an integer which is one of 0 `[]', 1 `[)', 2 `(]' or 3 `()', followed by the two limits of the interval.

The OFF key turns Calc off; typing M-# k or M-# M-# again has the same effect. This is analogous to typing q or hitting M-# c again in the normal calculator. If Calc is running standalone (the full-calc-keypad command appeared in the command line that started Emacs), then OFF is replaced with EXIT; clicking on this actually exits Emacs itself.

Functions Menu


This menu provides various operations from the f and k prefix keys.

IMAG multiplies the number on the stack by the imaginary number i = (0, 1).

RE extracts the real part a complex number. INV RE extracts the imaginary part.

RAND takes a number from the top of the stack and computes a random number greater than or equal to zero but less than that number. (See section Random Numbers.) RAGN is the "random again" command; it computes another random number using the same limit as last time.

INV GCD computes the LCM (least common multiple) function.

INV FACT is the gamma function. @c{$\Gamma(x) = (x-1)!$} gamma(x) = (x-1)!.

PERM is the number-of-permutations function, which is on the H k c key in normal Calc.

NXTP finds the next prime after a number. INV NXTP finds the previous prime.

Binary Menu

| A  | B  | C  | D  | E  | F  |

The keys in this menu perform operations on binary integers. Note that both logical and arithmetic right-shifts are provided. INV LSH rotates one bit to the left.

The "difference" function (normally on b d) is on INV AND. The "clip" function (normally on b c) is on INV NOT.

The DEC, HEX, OCT, and BIN keys select the current radix for display and entry of numbers: Decimal, hexadecimal, octal, or binary. The six letter keys A through F are used for entering hexadecimal numbers.

The WSIZ key displays the current word size for binary operations and allows you to enter a new word size. You can respond to the prompt using either the keyboard or the digits and ENTER from the keypad. The initial word size is 32 bits.

Vectors Menu


The keys in this menu operate on vectors and matrices.

PACK removes an integer n from the top of the stack; the next n stack elements are removed and packed into a vector, which is replaced onto the stack. Thus the sequence 1 ENTER 3 ENTER 5 ENTER 3 PACK enters the vector `[1, 3, 5]' onto the stack. To enter a matrix, build each row on the stack as a vector, then use a final PACK to collect the rows into a matrix.

UNPK unpacks the vector on the stack, pushing each of its components separately.

INDX removes an integer n, then builds a vector of integers from 1 to n. INV INDX takes three numbers from the stack: The vector size n, the starting number, and the increment. BLD takes an integer n and any value x and builds a vector of n copies of x.

IDNT removes an integer n, then builds an n-by-n identity matrix.

LEN replaces a vector by its length, an integer.

... turns on or off "abbreviated" display mode for large vectors.

MINV, MDET, MTRN, and CROSS are the matrix inverse, determinant, and transpose, and vector cross product.

SUM replaces a vector by the sum of its elements. It is equivalent to u + in normal Calc (see section Statistical Operations on Vectors). PROD computes the product of the elements of a vector, and MAX computes the maximum of all the elements of a vector.

INV SUM computes the alternating sum of the first element minus the second, plus the third, minus the fourth, and so on. INV MAX computes the minimum of the vector elements.

HYP SUM computes the mean of the vector elements. HYP PROD computes the sample standard deviation. HYP MAX computes the median.

MAP* multiplies two vectors elementwise. It is equivalent to the V M * command. MAP^ computes powers elementwise. The arguments must be vectors of equal length, or one must be a vector and the other must be a plain number. For example, 2 MAP^ squares all the elements of a vector.

MAP$ maps the formula on the top of the stack across the vector in the second-to-top position. If the formula contains several variables, Calc takes that many vectors starting at the second-to-top position and matches them to the variables in alphabetical order. The result is a vector of the same size as the input vectors, whose elements are the formula evaluated with the variables set to the various sets of numbers in those vectors. For example, you could simulate MAP^ using MAP$ with the formula `x^y'.

The "x" key pushes the variable name x onto the stack. To build the formula x^2 + 6, you would use the key sequence "x" 2 y^x 6 +. This formula would then be suitable for use with the MAP$ key described above. With INV, HYP, or INV and HYP, the "x" key pushes the variable names y, z, and t, respectively.

Modes Menu

|FLT |FIX |SCI |ENG |GRP |    |

The keys in this menu manipulate modes, variables, and the stack.

The FLT, FIX, SCI, and ENG keys select floating-point, fixed-point, scientific, or engineering notation. FIX displays two digits after the decimal by default; the others display full precision. With the INV prefix, these keys pop a number-of-digits argument from the stack.

The GRP key turns grouping of digits with commas on or off. INV GRP enables grouping to the right of the decimal point as well as to the left.

The RAD and DEG keys switch between radians and degrees for trigonometric functions.

The FRAC key turns Fraction mode on or off. This affects whether commands like / with integer arguments produce fractional or floating-point results.

The POLR key turns Polar mode on or off, determining whether polar or rectangular complex numbers are used by default.

The SYMB key turns Symbolic mode on or off, in which operations that would produce inexact floating-point results are left unevaluated as algebraic formulas.

The PREC key selects the current precision. Answer with the keyboard or with the keypad digit and ENTER keys.

The SWAP key exchanges the top two stack elements. The RLL3 key rotates the top three stack elements upwards. The RLL4 key rotates the top four stack elements upwards. The OVER key duplicates the second-to-top stack element.

The STO and RCL keys are analogous to s t and s r in regular Calc. See section Storing and Recalling. Click the STO or RCL key, then one of the ten digits. (Named variables are not available in Keypad Mode.) You can also use, for example, STO + 3 to add to register 3.

Go to the previous, next section.