home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
gnu
/
info
/
calc.info-9
(
.txt
)
< prev
next >
Wrap
GNU Info File
|
1994-12-22
|
51KB
|
838 lines
This is Info file calc.info, produced by Makeinfo-1.55 from the input
file calc.texinfo.
This file documents Calc, the GNU Emacs calculator.
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
that the section entitled "GNU General Public License" is included
exactly as in the original, and provided that the entire resulting
derived work is distributed under the terms of a permission notice
identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that the section entitled "GNU General Public License"
may be included in a translation approved by the author instead of in
the original English.
File: calc.info, Node: Caches, Next: Debugging Calc, Prev: Recursion Depth, Up: Troubleshooting Commands
Caches
------
Calc saves certain values after they have been computed once. For
example, the `P' (`calc-pi') command initially "knows" the constant
`pi' to about 20 decimal places; if the current precision is greater
than this, it will recompute `pi' using a series approximation. This
value will not need to be recomputed ever again unless you raise the
precision still further. Many operations such as logarithms and sines
make use of similarly cached values such as `pi/4' and `ln(2)'. The
visible effect of caching is that high-precision computations may seem
to do extra work the first time. Other things cached include powers of
two (for the binary arithmetic functions), matrix inverses and
determinants, symbolic integrals, and data points computed by the
graphing commands.
If you suspect a Calculator cache has become corrupt, you can use the
`calc-flush-caches' command to reset all caches to the empty state.
(This should only be necessary in the event of bugs in the Calculator.)
The `M-# 0' (with the zero key) command also resets caches along with
all other aspects of the Calculator's state.
File: calc.info, Node: Debugging Calc, Prev: Caches, Up: Troubleshooting Commands
Debugging Calc
--------------
A few commands exist to help in the debugging of Calc commands. *Note
Programming::, to see the various ways that you can write your own Calc
commands.
The `Z T' (`calc-timing') command turns on and off a mode in which
the timing of slow commands is reported in the Trail. Any Calc command
that takes two seconds or longer writes a line to the Trail showing how
many seconds it took. This value is accurate only to within one second.
All steps of executing a command are included; in particular, time
taken to format the result for display in the stack and trail is
counted. Some prompts also count time taken waiting for them to be
answered, while others do not; this depends on the exact implementation
of the command. For best results, if you are timing a sequence that
includes prompts or multiple commands, define a keyboard macro to run
the whole sequence at once. Calc's `X' command (*note Keyboard
Macros::.) will then report the time taken to execute the whole macro.
Another advantage of the `X' command is that while it is executing,
the stack and trail are not updated from step to step. So if you
expect the output of your test sequence to leave a result that may take
a long time to format and you don't wish to count this formatting time,
end your sequence with a DEL keystroke to clear the result from the
stack. When you run the sequence with `X', Calc will never bother to
format the large result.
Another thing `Z T' does is to increase the Emacs variable
`gc-cons-threshold' to a much higher value (two million; the usual
default in Calc is 250,000) for the duration of each command. This
generally prevents garbage collection during the timing of the command,
though it may cause your Emacs process to grow abnormally large.
(Garbage collection time is a major unpredictable factor in the timing
of Emacs operations.)
Another command that is useful when debugging your own Lisp
extensions to Calc is `M-x calc-pass-errors', which disables the error
handler that changes the "`max-lisp-eval-depth' exceeded" message to
the much more friendly "Computation got stuck or ran too long." This
handler interferes with the Emacs Lisp debugger's `debug-on-error'
mode. Errors are reported in the handler itself rather than at the
true location of the error. After you have executed
`calc-pass-errors', Lisp errors will be reported correctly but the
user-friendly message will be lost.
File: calc.info, Node: Data Types, Next: Stack and Trail, Prev: Introduction, Up: Top
Data Types
**********
This chapter discusses the various types of objects that can be placed
on the Calculator stack, how they are displayed, and how they are
entered. (*Note Data Type Formats::, for information on how these data
types are represented as underlying Lisp objects.)
Integers, fractions, and floats are various ways of describing real
numbers. HMS forms also for many purposes act as real numbers. These
types can be combined to form complex numbers, modulo forms, error
forms, or interval forms. (But these last four types cannot be combined
arbitrarily: error forms may not contain modulo forms, for example.)
Finally, all these types of numbers may be combined into vectors,
matrices, or algebraic formulas.
* Menu:
* Integers:: The most basic data type.
* Fractions:: This and above are called "rationals".
* Floats:: This and above are called "reals".
* Complex Numbers:: This and above are called "numbers".
* Infinities::
* Vectors and Matrices::
* Strings::
* HMS Forms::
* Date Forms::
* Modulo Forms::
* Error Forms::
* Interval Forms::
* Incomplete Objects::
* Variables::
* Formulas::
File: calc.info, Node: Integers, Next: Fractions, Prev: Data Types, Up: Data Types
Integers
========
The Calculator stores integers to arbitrary precision. Addition,
subtraction, and multiplication of integers always yields an exact
integer result. (If the result of a division or exponentiation of
integers is not an integer, it is expressed in fractional or
floating-point form according to the current Fraction Mode. *Note
Fraction Mode::.)
A decimal integer is represented as an optional sign followed by a
sequence of digits. Grouping (*note Grouping Digits::.) can be used to
insert a comma at every third digit for display purposes, but you must
not type commas during the entry of numbers.
A non-decimal integer is represented as an optional sign, a radix
between 2 and 36, a `#' symbol, and one or more digits. For radix 11
and above, the letters A through Z (upper- or lower-case) count as
digits and do not terminate numeric entry mode. *Note Radix Modes::,
for how to set the default radix for display of integers. Numbers of
any radix may be entered at any time. If you press `#' at the
beginning of a number, the current display radix is used.
File: calc.info, Node: Fractions, Next: Floats, Prev: Integers, Up: Data Types
Fractions
=========
A "fraction" is a ratio of two integers. Fractions are traditionally
written "2/3" but Calc uses the notation `2:3'. (The `/' key performs
RPN division; the following two sequences push the number `2:3' on the
stack: `2 : 3 RET', or `2 RET 3 /' assuming Fraction Mode has been
enabled.) When the Calculator produces a fractional result it always
reduces it to simplest form, which may in fact be an integer.
Fractions may also be entered in a three-part form, where `2:3:4'
represents two-and-three-quarters. *Note Fraction Formats::, for
fraction display formats.
Non-decimal fractions are entered and displayed as `RADIX#NUM:DENOM'
(or in the analogous three-part form). The numerator and denominator
always use the same radix.
File: calc.info, Node: Floats, Next: Complex Numbers, Prev: Fractions, Up: Data Types
Floats
======
A floatin