www.delorie.com/gnu/docs/calc/calc_193.html   search  
Buy the book!

GNU Emacs Calc 2.02 Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.9 The Modes Variable

The m g (calc-get-modes) command pushes onto the stack a vector of numbers that describes the various mode settings that are in effect. With a numeric prefix argument, it pushes only the nth mode, i.e., the nth element of this vector. Keyboard macros can use the m g command to modify their behavior based on the current mode settings.

The modes vector is also available in the special variable Modes. In other words, m g is like s r Modes RET. It will not work to store into this variable; in fact, if you do, Modes will cease to track the current modes. (The m g command will continue to work, however.)

In general, each number in this vector is suitable as a numeric prefix argument to the associated mode-setting command. (Recall that the ~ key takes a number from the stack and gives it as a numeric prefix to the next command.)

The elements of the modes vector are as follows:

  1. Current precision. Default is 12; associated command is p.

  2. Binary word size. Default is 32; associated command is b w.

  3. Stack size (not counting the value about to be pushed by m g). This is zero if m g is executed with an empty stack.

  4. Number radix. Default is 10; command is d r.

  5. Floating-point format. This is the number of digits, plus the constant 0 for normal notation, 10000 for scientific notation, 20000 for engineering notation, or 30000 for fixed-point notation. These codes are acceptable as prefix arguments to the d n command, but note that this may lose information: For example, d s and C-u 12 d s have similar (but not quite identical) effects if the current precision is 12, but they both produce a code of 10012, which will be treated by d n as C-u 12 d s. If the precision then changes, the float format will still be frozen at 12 significant figures.

  6. Angular mode. Default is 1 (degrees). Other values are 2 (radians) and 3 (HMS). The m d command accepts these prefixes.

  7. Symbolic mode. Value is 0 or 1; default is 0. Command is m s.

  8. Fraction mode. Value is 0 or 1; default is 0. Command is m f.

  9. Polar mode. Value is 0 (rectangular) or 1 (polar); default is 0. Command is m p.

  10. Matrix/scalar mode. Default value is -1. Value is 0 for scalar mode, -2 for matrix mode, or N for NxN matrix mode. Command is m v.

  11. Simplification mode. Default is 1. Value is -1 for off (m O), 0 for m N, 2 for m B, 3 for m A, 4 for m E, or 5 for m U. The m D command accepts these prefixes.

  12. Infinite mode. Default is -1 (off). Value is 1 if the mode is on, or 0 if the mode is on with positive zeros. Command is m i.

For example, the sequence M-1 m g RET 2 + ~ p increases the precision by two, leaving a copy of the old precision on the stack. Later, ~ p will restore the original precision using that stack value. (This sequence might be especially useful inside a keyboard macro.)

As another example, M-3 m g 1 - ~ DEL deletes all but the oldest (bottommost) stack entry.

Yet another example: The HP-48 "round" command rounds a number to the current displayed precision. You could roughly emulate this in Calc with the sequence M-5 m g 10000 % ~ c c. (This would not work for fixed-point mode, but it wouldn't be hard to do a full emulation with the help of the Z [ and Z ] programming commands. See section 18.2.2 Conditionals in Keyboard Macros.)

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003