home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
misc
/
volume24
/
gnucalc
/
part39
< prev
next >
Wrap
Text File
|
1991-10-31
|
57KB
|
1,344 lines
Newsgroups: comp.sources.misc
From: daveg@synaptics.com (David Gillespie)
Subject: v24i087: gnucalc - GNU Emacs Calculator, v2.00, Part39/56
Message-ID: <1991Oct31.214712.2839@sparky.imd.sterling.com>
X-Md4-Signature: 9b416ed166b003463af7e0476aa6901b
Date: Thu, 31 Oct 1991 21:47:12 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: daveg@synaptics.com (David Gillespie)
Posting-number: Volume 24, Issue 87
Archive-name: gnucalc/part39
Environment: Emacs
Supersedes: gmcalc: Volume 13, Issue 27-45
---- Cut Here and unpack ----
#!/bin/sh
# do not concatenate these parts, unpack them in order with /bin/sh
# file calc.texinfo continued
#
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 39; then
echo Please unpack part "$Scheck" next!
exit 1
else
exit 0
fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
echo 'x - still skipping calc.texinfo'
else
echo 'x - continuing file calc.texinfo'
sed 's/^X//' << 'SHAR_EOF' >> 'calc.texinfo' &&
(@pxref{Selecting Subformulas}). Use matrix mode when operating on
your formula normally; then, to apply scalar mode to a certain part
of the formula without affecting the rest just select that part,
change into scalar mode and press @kbd{=} to resimplify the part
under this mode, then change back to matrix mode before deselecting.
X
@node Automatic Recomputation, Working Message, Matrix Mode, Calculation Modes
@subsection Automatic Recomputation
X
@noindent
The @dfn{evaluates-to} operator, @samp{=>}, has the special
property that any @samp{=>} formulas on the stack are recomputed
whenever variable values or mode settings that might affect them
are changed. @xref{Evaluates-To Operator}.
X
@kindex m C
@pindex calc-auto-recompute
The @kbd{m C} (@code{calc-auto-recompute}) command turns this
automatic recomputation on and off. If you turn it off, Calc will
not update @samp{=>} operators on the stack (nor those in the
attached Embedded Mode buffer, if there is one). They will not
be updated unless you explicitly do so by pressing @kbd{=} or until
you press @kbd{m C} to turn recomputation back on. (While automatic
recomputation is off, you can think of @kbd{m C m C} as a command
to update all @samp{=>} operators while leaving recomputation off.)
X
To update @samp{=>} operators in an Embedded buffer while
automatic recomputation is off, use @kbd{M-# u}.
@xref{Embedded Mode}.
X
@node Working Message, , Automatic Recomputation, Calculation Modes
@subsection Working Messages
X
@noindent
@cindex Performance
@cindex Working messages
Since the Calculator is written entirely in Emacs Lisp, which is not
designed for heavy numerical work, many operations are quite slow.
The Calculator normally displays the message @samp{Working...} in the
echo area during any command that may be slow. In addition, iterative
operations such as square roots and trigonometric functions display the
intermediate result at each step. Both of these types of messages can
be disabled if you find them distracting.
X
@kindex m w
@pindex calc-working
Type @kbd{m w} (@code{calc-working}) with a numeric prefix of 0 to
disable all ``working'' messages. Use a numeric prefix of 1 to enable
only the plain @samp{Working...} message. Use a numeric prefix of 2 to
see intermediate results as well. With no numeric prefix this displays
the current mode.@refill
X
@node Simplification Modes, Declarations, Calculation Modes, Mode Settings
@section Simplification Modes
X
@noindent
The current @dfn{simplification mode} controls how numbers and formulas
are ``normalized'' when being taken from or pushed onto the stack.
Some normalizations are unavoidable, such as rounding floating-point
results to the current precision, and reducing fractions to simplest
form. Others, such as simplifying a formula like @cite{a+a} (or @cite{2+3}),
are done by default but can be turned off when necessary.
X
When you press a key like @kbd{+} when @cite{2} and @cite{3} are on the
stack, Calc pops these numbers, normalizes them, creates the formula
@cite{2+3}, normalizes it, and pushes the result. Of course the standard
rules for normalizing @cite{2+3} will produce the result @cite{5}.
X
Simplification mode commands consist of the lower-case @kbd{m} prefix key
followed by a shifted letter.
X
@kindex m O
@pindex calc-no-simplify-mode
The @kbd{m O} (@code{calc-no-simplify-mode}) command turns off all optional
simplifications. These would leave a formula like @cite{2+3} alone. In
fact, nothing except simple numbers are ever affected by normalization
in this mode.
X
@kindex m N
@pindex calc-num-simplify-mode
The @kbd{m N} (@code{calc-num-simplify-mode}) command turns off simplification
of any formulas except those for which all arguments are constants. For
example, @cite{1+2} is simplified to @cite{3}, and @cite{a+(2-2)} is
simplified to @cite{a+0} but no further, since one argument of the sum
is not a constant. Unfortunately, @cite{(a+2)-2} is @emph{not} simplified
because the top-level @samp{-} operator's arguments are not both
constant numbers (one of them is the formula @samp{a+2}).
A constant is a number or other numeric object (such as a constant
error form or modulo form), or a vector all of whose
elements are constant.@refill
X
@kindex m D
@pindex calc-default-simplify-mode
The @kbd{m D} (@code{calc-default-simplify-mode}) command restores the
default simplifications for all formulas. This includes some easy and
fast simplifications such as @cite{a+0} to @cite{a}, and @cite{a + 2 a}
to @cite{3 a}.
X
@kindex m B
@pindex calc-bin-simplify-mode
The @kbd{m B} (@code{calc-bin-simplify-mode}) mode applies the default
simplifications to a result and then, if the result is an integer,
uses the @kbd{b c} (@code{calc-clip}) command to clip the integer according
to the current binary word size. @xref{Binary Functions}. Real numbers
are rounded to the nearest integer and then clipped; other kinds of
results (after the default simplifications) are left alone.
X
@kindex m A
@pindex calc-alg-simplify-mode
The @kbd{m A} (@code{calc-alg-simplify-mode}) mode does algebraic
simplification; it applies all the default simplifications, and also
the more powerful (and slower) simplifications made by @kbd{a s}
(@code{calc-simplify}). @xref{Algebra}.
X
@kindex m E
@pindex calc-ext-simplify-mode
The @kbd{m E} (@code{calc-ext-simplify-mode}) mode does ``extended''
algebraic simplification, as by the @kbd{a e} (@code{calc-simplify-extended})
command. @xref{Algebra}.
X
@kindex m U
@pindex calc-units-simplify-mode
The @kbd{m U} (@code{calc-units-simplify-mode}) mode does units
simplification; it applies the command @kbd{u s}
(@code{calc-simplify-units}), which in turn
is a superset of @code{calc-simplify}. In this mode, variable names
which are identifiable as unit names (like @samp{mm} for ``millimeters'')
are simplified with their unit definitions in mind.@refill
X
A common technique is to set the simplification mode down to the lowest
amount of simplification you will allow to be applied automatically, then
use manual commands like @code{calc-clean} or @code{calc-simplify} to
perform higher types of simplifications on demand. @xref{Algebraic
Definitions}, for another sample use of no-simplification mode.@refill
X
@node Declarations, Display Modes, Simplification Modes, Mode Settings
@section Declarations
X
@noindent
A @dfn{declaration} is a statement you make that promises you will
use a certain variable or function in a restricted way. This may
give Calc the freedom to do things that it couldn't do if it had to
take the fully general situation into account.
X
@menu
* Declaration Basics::
* Kinds of Declarations::
* Functions for Declarations::
@end menu
X
@node Declaration Basics, Kinds of Declarations, Declarations, Declarations
@subsection Declaration Basics
X
@noindent
@kindex s d
@pindex calc-declare-variable
The @kbd{s d} (@code{calc-declare-variable}) command is the easiest
way to make a declaration for a variable. This command prompts for
the variable name, then prompts for the declaration. The default
at the declaration prompt is the previous declaration, if any.
You can edit this declaration, or press @kbd{C-k} to erase it and
type a new declaration. (Or, erase it and press @key{RET} to clear
the declaration, effectively ``undeclaring'' the variable.)
X
A declaration is in general a vector of @dfn{type symbols} and
@dfn{range} values. If there is only one type symbol or range value,
you can write it directly rather than enclosing it in a vector.
For example, @kbd{s d foo RET real RET} declares @code{foo} to
be a real number, and @kbd{s d bar RET [int, const, [1..6]] RET}
declares @code{bar} to be an integer constant between 1 and 6.
(Actually, you can omit the outermost brackets and Calc will
provide them for you: @kbd{s d bar RET int, const, [1..6] RET}.)
X
@cindex @code{Decls} variable
@vindex Decls
Declarations in Calc are kept in a special variable called @code{Decls}.
This variable encodes the set of all outstanding declarations in
the form of a matrix. Each row has two elements: A variable or
vector of variables declared by that row, and the declaration
specifier as described above. You can use the @kbd{s D} command to
edit this variable if you wish to see all the declarations at once.
@xref{Operations on Variables}, for a description of this command
and the @kbd{s p} command that allows you to save your declarations
permanently if you wish.
X
Items being declared can also be function calls. The arguments in
the call are ignored; the effect is to say that this function returns
values of the declared type for any valid arguments. The @kbd{s d}
command declares only variables, so if you wish to make a function
declaration you will have to edit the @code{Decls} matrix yourself.
X
For example, the declaration matrix
X
@group
@smallexample
[ [ foo, real ]
X [ [j, k, n], int ]
X [ f(1,2,3), [0 .. inf) ] ]
@end smallexample
@end group
X
@noindent
declares that @code{foo} represents a real number, @code{j}, @code{k}
and @code{n} represent integers, and the function @code{f} always
returns a real number in the interval shown.
X
@vindex All
If there is a declaration for the variable @code{All}, then that
declaration applies to all variables that are not otherwise declared.
It does not apply to function names. For example, using the row
@samp{[All, real]} says that all your variables are real unless they
are explicitly declared without @code{real} in some other row.
The @kbd{s d} command declares @code{All} if you give a blank
response to the variable-name prompt.
X
@node Kinds of Declarations, Functions for Declarations, Declaration Basics, Declarations
@subsection Kinds of Declarations
X
@noindent
The type-specifier part of a declaration (that is, the second prompt
in the @kbd{s d} command) can be a type symbol, an interval, or a
vector consisting of zero or more type symbols followed by zero or
more intervals or numbers that represent the set of possible values
for the variable.
X
@group
@smallexample
[ [ a, [1, 2, 3, 4, 5] ]
X [ b, [1 .. 5] ]
X [ c, [int, 1 .. 5] ] ]
@end smallexample
@end group
X
Here @code{a} is declared to contain one of the five integers shown;
@code{b} is any number in the interval from 1 to 5 (any real number
since we haven't specified), and @code{c} is any integer in that
interval. Thus the declarations for @code{a} and @code{c} are
nearly equivalent (see below).
X
The type-specifier can be the empty vector @samp{[]} to say that
nothing is known about a given variable's value. This is the same
as not declaring the variable at all except that it overrides any
@code{All} declaration which would otherwise apply.
X
The initial value of @code{Decls} is the empty vector @samp{[]}.
If @code{Decls} has no stored value or if the value stored in it
is not valid, it is ignored and there are no declarations as far
as Calc is concerned. (The @kbd{s d} command will replace such a
malformed value with a fresh empty matrix, @samp{[]}, before recording
the new declaration.) Unrecognized type symbols are ignored.
X
The following type symbols are recognized to describe what sorts of
numbers will be stored in a variable:
X
@table @code
@item int
Integers.
@item numint
Numerical integers. (Integers or integer-valued floats.)
@item frac
Fractions. (Rational numbers which are not integers.)
@item rat
Rational numbers. (Either integers or fractions.)
@item float
Floating-point numbers.
@item real
Real numbers. (Integers, fractions, or floats. Actually,
intervals and error forms with real components also count as
reals here.)
@item pos
Positive real numbers. (Strictly greater than zero.)
@item nonneg
Nonnegative real numbers. (Greater than or equal to zero.)
@item number
Numbers. (Real or complex.)
@end table
X
Calc uses this information to determine when certain simplifications
of formulas are safe. For example, @samp{(x^y)^z} can not be
simplified to @samp{x^(y z)} in general; for example,
@samp{((-3)^2)^1:2} is 3, but @samp{(-3)^(2*1:2) = (-3)^1} is @i{-3}.
However, this simplification @emph{is} safe if @code{z} is known
to be an integer, or if @code{x} is known to be a nonnegative
real number. If you have given declarations that allow Calc to
deduce either of these facts, Calc will perform this simplification
of the formula.
X
Calc can apply a certain amount of logic when using declarations.
For example, @samp{(x^y)^(2n+1)} will be simplified if @code{n}
has been declared @code{int}; Calc knows that an integer times an
integer, plus an integer, must always be an integer. (In fact,
Calc would simplify @samp{(-x)^(2n+1)} to @samp{-(x^(2n+1))} since
it is able to determine that @samp{2n+1} must be an odd integer.)
X
Similarly, @samp{(abs(x)^y)^z} will be simplified to @samp{abs(x)^(y z)}
because Calc knows that the @code{abs} function always returns a
nonnegative real. If you had a @code{myabs} function that also had
this property, you could get Calc to recognize it by adding the row
@samp{[myabs(), nonneg]} to the @code{Decls} matrix.
X
One instance of this simplification is @samp{sqrt(x^2)} (since the
@code{sqrt} function is effectively a one-half power). Normally
Calc leaves this formula alone. After the command
@kbd{s d x RET real RET}, however, it can simplify the formula to
@samp{abs(x)}. And after @kbd{s d x RET nonneg RET}, Calc can
simplify this formula all the way to @samp{x}.
X
If there are any intervals or real numbers in the type specifier,
they comprise the set of possible values that the variable or
function being declared can have. In particular, the type symbol
@code{real} is effectively the same as the range @samp{[-inf .. inf]}
(note that infinity is included in the range of possible values);
@code{pos} is the same as @samp{(0 .. inf]}, and @code{nonneg} is
the same as @samp{[0 .. inf]}. Saying @samp{[real, [-5 .. 5]]} is
redundant because the fact that the variable is real can be
deduced just from the interval, but @samp{[int, [-5 .. 5]]} and
@samp{[rat, [-5 .. 5]]} are useful combinations.
X
Note that the vector of intervals or numbers is in the same format
used by Calc's set-manipulation commands. @xref{Set Operations}.
X
The type specifier @samp{[1, 2, 3]} is equivalent to
@samp{[numint, 1, 2, 3]}, @emph{not} to @samp{[int, 1, 2, 3]}.
In other words, the range of possible values means only that
the variable's value must be numerically equal to a number in
that range, but not that it must be equal in type as well.
Calc's set operations act the same way; @samp{in(2, [1., 2., 3.])}
and @samp{in(1.5, [1:2, 3:2, 5:2])} both report ``true.''
X
If you use a conflicting combination of type specifiers, the
results are unpredictable. An example is @samp{[pos, [0 .. 5]]},
where the interval does not lie in the range described by the
type symbol.
X
``Real'' declarations mostly affect simplifications involving powers
like the one described above. Another case where they are used
is in the @kbd{a P} command which returns a list of all roots of a
polynomial; if the variable has been declared real, only the real
roots (if any) will be included in the list.
X
``Integer'' declarations are used for simplifications which are valid
only when certain values are integers (such as @samp{(x^y)^z}
shown above).
X
Another command that makes use of declarations is @kbd{a s}, when
simplifying equations and inequalities. It will cancel @code{x}
from both sides of @samp{a x = b x} only if it is sure @code{x}
is non-zero, say, because it has a @code{pos} declaration.
To declare specifically that @code{x} is real and non-zero,
use @samp{[[-inf .. 0), (0 .. inf]]}. (There is no way in the
current notation to say that @code{x} is nonzero but not necessarily
real.) The @kbd{a e} command does ``unsafe'' simplifications,
including cancelling @samp{x} from the equation when @samp{x} is
not known to be nonzero.
X
Another set of type symbols distinguish between scalars and vectors.
X
@table @code
@item scalar
The value is not a vector.
@item vector
The value is a vector.
@item matrix
The value is a matrix (a rectangular vector of vectors).
@end table
X
These type symbols can be combined with the other type symbols
described above; @samp{[int, matrix]} describes an object which
is a matrix of integers.
X
Scalar/vector declarations are used to determine whether certain
algebraic operations are safe. For example, @samp{[a, b, c] + x}
is normally not simplified to @samp{[a + x, b + x, c + x]}, but
it will be if @code{x} has been declared @code{scalar}. On the
other hand, multiplication is usually assumed to be commutative,
but the terms in @samp{x y} will never be exchanged if both @code{x}
and @code{y} are known to be vectors or matrices. (Calc currently
never distinguishes between @code{vector} and @code{matrix}
declarations.)
X
@xref{Matrix Mode}, for a discussion of ``matrix mode'' and
``scalar mode,'' which are similar to declaring @samp{[All, matrix]}
or @samp{[All, scalar]} but much more convenient.
X
One more type symbol that is recognized is used with the @kbd{H a d}
command for taking total derivatives of a formula. @xref{Calculus}.
X
@table @code
@item const
The value is a constant with respect to other variables.
@end table
X
Calc does not check the declarations for a variable when you store
a value in it. However, storing @i{-3.5} in a variable that has
been declared @code{pos}, @code{int}, or @code{matrix} may have
unexpected effects; Calc may evaluate @samp{sqrt(x^2)} to @cite{3.5}
if it substitutes the value first, or to @cite{-3.5} if @code{x}
was declared @code{pos} and the formula @samp{sqrt(x^2)} is
simplified to @samp{x} before the value is substituted. Before
using a variable for a new purpose, it is best to use @kbd{s d}
or @kbd{s D} to check to make sure you don't still have an old
declaration for the variable that will conflict with its new meaning.
X
@node Functions for Declarations, , Kinds of Declarations, Declarations
@subsection Functions for Declarations
X
@noindent
Calc has a set of functions for accessing the current declarations
in a convenient manner. These functions return 1 if the argument
can be shown to have the specified property, or 0 if the argument
can be shown @emph{not} to have that property; otherwise they are
left unevaluated. These functions are suitable for use with rewrite
rules (@pxref{Conditional Rewrite Rules}) or programming constructs
(@pxref{Conditionals in Macros}). They can be entered only using
algebraic notation. @xref{Logical Operations}, for functions
that perform other tests not related to declarations.
X
For example, @samp{dint(17)} returns 1 because 17 is an integer, as
do @samp{dint(n)} and @samp{dint(2 n - 3)} if @code{n} has been declared
@code{int}, but @samp{dint(2.5)} and @samp{dint(n + 0.5)} return 0.
Calc consults knowledge of its own built-in functions as well as your
own declarations: @samp{dint(floor(x))} returns 1.
X
@tindex dint
@tindex dnumint
@tindex dnatnum
The @code{dint} function checks if its argument is an integer.
The @code{dnatnum} function checks if its argument is a natural
number, i.e., a nonnegative integer. The @code{dnumint} function
checks if its argument is numerically an integer, i.e., either an
integer or an integer-valued float. Note that these and the other
data type functions also accept vectors or matrices composed of
suitable elements, and that real infinities @samp{inf} and @samp{-inf}
are considered to be integers for the purposes of these functions.
X
@tindex drat
The @code{drat} function checks if its argument is rational, i.e.,
an integer or fraction. Infinities count as rational, but intervals
and error forms do not.
X
@tindex dreal
The @code{dreal} function checks if its argument is real. This
includes integers, fractions, floats, real error forms, and intervals.
X
@tindex dimag
The @code{dimag} function checks if its argument is imaginary,
i.e., is mathematically equal to a real number times @cite{i}.
X
@tindex dpos
@tindex dneg
@tindex dnonneg
The @code{dpos} function checks for positive (but nonzero) reals.
The @code{dneg} function checks for negative reals. The @code{dnonneg}
function checks for nonnegative reals, i.e., reals greater than or
equal to zero. Note that the @kbd{a s} command can simplify an
expression like @cite{x > 0} to 1 or 0 using @code{dpos}, and that
@kbd{a s} is effectively applied to all conditions in rewrite rules,
so the actual functions @code{dpos}, @code{dneg}, and @code{dnonneg}
are rarely necessary.
X
@tindex dnonzero
The @code{dnonzero} function checks that its argument is nonzero.
This includes all nonzero real or complex numbers, all intervals that
do not include zero, all nonzero modulo forms, vectors all of whose
elements are nonzero, and variables or formulas whose values can be
deduced to be nonzero. It does not include error forms, since they
represent values which could be anything including zero. (This is
also the set of objects considered ``true'' in conditional contexts.)
X
@tindex deven
@tindex dodd
The @code{deven} function returns 1 if its argument is known to be
an even integer (or integer-valued float); it returns 0 if its argument
is known not to be even (because it is known to be odd or a non-integer).
This is a convenient shorthand for using @kbd{a s} to simplify a test
of the form @samp{x % 2 = 0}. There is also an analogous @code{dodd}
function.
X
@tindex drange
The @code{drange} function returns a set (an interval or a vector
of intervals and/or numbers; @pxref{Set Operations}) that describes
the set of possible values of its argument. If the argument is
a variable or a function with a declaration, the range is copied
from the declaration. Otherwise, the possible signs of the
expression are determined using a method similar to @code{dpos},
etc., and a suitable set like @samp{[0 .. inf]} is returned. If
the expression is not provably real, the @code{drange} function
remains unevaluated.
X
@tindex dscalar
The @code{dscalar} function returns 1 if its argument is provably
scalar, or 0 if its argument is provably non-scalar. It is left
unevaluated if this cannot be determined. (If matrix mode or scalar
mode are in effect, this function returns 1 or 0, respectively,
if it has no other information.) When Calc interprets a condition
(say, in a rewrite rule) it considers an unevaluated formula to be
``false.'' Thus, @samp{dscalar(a)} is ``true'' only if @code{a} is
provably scalar, and @samp{!dscalar(a)} is ``true'' only if @code{a}
is provably non-scalar; both are ``false'' if there is insufficient
information to tell.
X
@node Display Modes, Language Modes, Declarations, Mode Settings
@section Display Modes
X
@noindent
The commands in this section are two-key sequences beginning with the
@kbd{d} prefix. The @kbd{d l} (@code{calc-line-numbering}) and @kbd{d b}
(@code{calc-line-breaking}) commands are described elsewhere;
@pxref{Stack Basics} and @pxref{Normal Language Modes}, respectively.
Display formats for vectors and matrices are also covered elsewhere;
@pxref{Vector and Matrix Formats}.@refill
X
One thing all display modes have in common is their treatment of the
@kbd{H} prefix. This prefix causes any mode command that would normally
refresh the stack to leave the stack display alone. The word ``Dirty''
will appear in the mode line when Calc thinks the stack display may not
reflect the latest mode settings.
X
@kindex d RET
@pindex calc-refresh-top
The @kbd{d RET} (@code{calc-refresh-top}) command reformats the
top stack entry according to all the current modes. Positive prefix
arguments reformat the top @var{n} entries; negative prefix arguments
reformat the specified entry, and a prefix of zero is equivalent to
@kbd{d SPC} (@code{calc-refresh}), which reformats the entire stack.
For example, @kbd{H d s M-2 d RET} changes to scientific notation
but reformats only the top two stack entries in the new mode.
X
The @kbd{I} prefix has another effect on the display modes. The mode
is set only temporarily; the top stack entry is reformatted according
to that mode, then the original mode setting is restored. In other
words, @kbd{I d s} is equivalent to @kbd{H d s d RET H d @var{(old mode)}}.
X
@menu
* Radix Modes::
* Grouping Digits::
* Float Formats::
* Complex Formats::
* Fraction Formats::
* HMS Formats::
* Date Formats::
* Truncating the Stack::
* Justification::
* Labels::
@end menu
X
@node Radix Modes, Grouping Digits, Display Modes, Display Modes
@subsection Radix Modes
X
@noindent
@cindex Radix display
@cindex Non-decimal numbers
@cindex Decimal and non-decimal numbers
Calc normally displays numbers in decimal (@dfn{base-10} or @dfn{radix-10})
notation. Calc can actually display in any radix from two (binary) to 36.
When the radix is above 10, the letters @samp{A} to @samp{Z} are used as
digits. When entering such a number, letter keys are interpreted as
potential digits rather than terminating numeric entry mode.
X
@kindex d 2
@kindex d 8
@kindex d 6
@kindex d 0
@cindex Hexadecimal integers
@cindex Octal integers
The key sequences @kbd{d 2}, @kbd{d 8}, @kbd{d 6}, and @kbd{d 0} select
binary, octal, hexadecimal, and decimal as the current display radix,
respectively. Numbers can always be entered in any radix, though the
current radix is used as a default if you press @kbd{#} without any initial
digits. A number entered without a @kbd{#} is @emph{always} interpreted
as decimal.@refill
X
@kindex d r
@pindex calc-radix
To set the radix generally, use @kbd{d r} (@code{calc-radix}) and enter
an integer from 2 to 36. You can specify the radix as a numeric prefix
argument; otherwise you will be prompted for it.
X
@kindex d z
@pindex calc-leading-zeros
@cindex Leading zeros
Integers normally are displayed with however many digits are necessary to
represent the integer and no more. The @kbd{d z} (@code{calc-leading-zeros})
command causes integers to be padded out with leading zeros according to the
current binary word size. (@xref{Binary Functions}, for a discussion of
word size.) If the absolute value of the word size is @cite{w}, all integers
are displayed with at least enough digits to represent @c{$2^w-1$}
@cite{(2^w)-1} in the
current radix. (Larger integers will still be displayed in their entirety.)
X
@node Grouping Digits, Float Formats, Radix Modes, Display Modes
@subsection Grouping Digits
X
@noindent
@kindex d g
@pindex calc-group-digits
@cindex Grouping digits
@cindex Digit grouping
Long numbers can be hard to read if they have too many digits. For
example, the factorial of 30 is 33 digits long! Press @kbd{d g}
(@code{calc-group-digits}) to enable @dfn{grouping} mode, in which digits
are displayed in clumps of 3 or 4 (depending on the current radix)
separated by commas.
X
The @kbd{d g} command toggles grouping on and off.
With a numerix prefix of 0, this command displays the current state of
the grouping flag; with a @kbd{C-u} prefix, it pushes the grouping state
onto the stack; with an argument of minus one it disables grouping; with
a positive argument @cite{N} it enables grouping on every @cite{N}
digits. For floating-point numbers, grouping normally occurs only
before the decimal point. A negative prefix argument @cite{-N} enables
grouping every @cite{N} digits both before and after the decimal point.@refill
X
@kindex d ,
@pindex calc-group-char
The @kbd{d ,} (@code{calc-group-char}) command allows you to choose any
character as the grouping separator. The default is the comma character.
If you find it difficult to read vectors of large integers grouped with
commas, you may wish to use spaces or some other character instead.
This command takes the next character you type, whatever it is, and
uses it as the digit separator. As a special case, @kbd{d , \} selects
@samp{\,} (@TeX{}'s thin-space symbol) as the digit separator.
X
Please note that grouped numbers will not generally be parsed correctly
if re-read in textual form, say by the use of @kbd{M-# y} and @kbd{M-# g}.
(@xref{Kill and Yank}, for details on these commands.) One exception is
the @samp{\,} separator, which doesn't interfere with parsing because it
is ignored by @TeX{} language mode.
X
@node Float Formats, Complex Formats, Grouping Digits, Display Modes
@subsection Float Formats
X
@noindent
Floating-point quantities are normally displayed in standard decimal
form, with scientific notation used if the exponent is especially high
or low. All significant digits are normally displayed. The commands
in this section allow you to choose among several alternative display
formats for floats.
X
@kindex d n
@pindex calc-normal-notation
The @kbd{d n} (@code{calc-normal-notation}) command selects the normal
display format. All significant figures in a number are displayed.
With a positive numeric prefix, numbers are rounded if necessary to
that number of significant digits. With a negative numerix prefix,
the specified number of significant digits less than the current
precision is used. (Thus @kbd{C-u -2 d n} displays 10 digits if the
current precision is 12.)
X
@kindex d f
@pindex calc-fix-notation
The @kbd{d f} (@code{calc-fix-notation}) command selects fixed-point
notation. The numeric argument is the number of digits after the
decimal point, zero or more. This format will relax into scientific
notation if a nonzero number would otherwise have been rounded all the
way to zero. Specifying a negative number of digits is the same as
for a positive number, except that small nonzero numbers will be rounded
to zero rather than switching to scientific notation.
X
@kindex d s
@pindex calc-sci-notation
The @kbd{d s} (@code{calc-sci-notation}) command selects scientific
notation. A positive argument sets the number of significant figures
displayed, of which one will be before and the rest after the decimal
point. A negative argument works the same as for @kbd{d n} format.
The default is to display all significant digits.
X
@kindex d e
@pindex calc-eng-notation
The @kbd{d e} (@code{calc-eng-notation}) command selects engineering
notation. This is similar to scientific notation except that the
exponent is rounded down to a multiple of three, with from one to three
digits before the decimal point. An optional numeric prefix sets the
number of significant digits to display, as for @kbd{d s}.
X
It is important to distinguish between the current @emph{precision} and
the current @emph{display format}. After the commands @kbd{C-u 10 p}
and @kbd{C-u 6 d n} the Calculator computes all results to ten
significant figures but only displays six. (In fact, intermediate
calculations are often carried to one or two more significant figures,
but values placed on the stack are always rounded down to ten figures.)
Numbers are never actually rounded to the display precision for storage,
except by commands like @kbd{C-k} and @kbd{M-# y} which operate on the
actual displayed text in the Calculator buffer.
X
@kindex d .
@pindex calc-point-char
The @kbd{d .} (@code{calc-point-char}) command controls the character used
as a decimal point. Normally this is a period; users in some countries
may wish to change this to a comma. Note that this is only a display
style; on entry, periods must always be used to denote floating-point
numbers, and commas to separate elements in a list.
X
@node Complex Formats, Fraction Formats, Float Formats, Display Modes
@subsection Complex Formats
X
@noindent
@kindex d c
@pindex calc-complex-notation
There are three supported notations for complex numbers in rectangular
form. The default is as a pair of real numbers enclosed in parentheses
and separated by a comma: @samp{(a,b)}. The @kbd{d c}
(@code{calc-complex-notation}) command selects this style.@refill
X
@kindex d i
@pindex calc-i-notation
@kindex d j
@pindex calc-j-notation
The other notations are @kbd{d i} (@code{calc-i-notation}), in which
numbers are displayed in @samp{a+bi} form, and @kbd{d j}
(@code{calc-j-notation}) which displays the form @samp{a+bj} preferred
in some disciplines.@refill
X
@cindex @code{i} variable
@vindex i
Complex numbers are normally entered in @samp{(a,b)} format.
If you enter @samp{2+3i} as an algebraic formula, it will be stored as
the formula @samp{2 + 3 * i}. However, if you use @kbd{=} to evaluate
this formula and you have not changed the variable @samp{i}, the @samp{i}
will be interpreted as @samp{(0,1)} and the formula will be simplified
to @samp{(2,3)}. Other commands (like @code{calc-sin}) will @emph{not}
interpret the formula @samp{2 + 3 * i} as a complex number.
@xref{Variables}, under ``special constants.''@refill
X
@node Fraction Formats, HMS Formats, Complex Formats, Display Modes
@subsection Fraction Formats
X
@noindent
@kindex d o
@pindex calc-over-notation
Display of fractional numbers is controlled by the @kbd{d o}
(@code{calc-over-notation}) command. By default, a number like
eight thirds is displayed in the form @samp{8:3}. The @kbd{d o} command
prompts for a one- or two-character format. If you give one character,
that character is used as the fraction separator. Common separators are
@samp{:} and @samp{/}. (During input of numbers, the @kbd{:} key must be
used regardless of the display format; in particular, the @kbd{/} is used
for RPN-style division, @emph{not} for entering fractions.)
X
If you give two characters, fractions use ``integer-plus-fractional-part''
notation. For example, the format @samp{+/} would display eight thirds
as @samp{2+2/3}. If two colons are present in a number being entered,
the number is interpreted in this form.
X
It is also possible to follow the one- or two-character format with
a number. For example: @samp{:10} or @samp{+/3}. In this case,
Calc adjusts all fractions that are displayed to have the specified
denominator, if possible. Otherwise it adjusts the denominator to
be a multiple of the specified value. For example, in @samp{:6} mode
the fraction @cite{1:6} will be unaffected, but @cite{2:3} will be
displayed as @cite{4:6}, @cite{1:2} will be displayed as @cite{3:6},
and @cite{1:8} will be displayed as @cite{3:24}. Integers are also
affected by this mode: 3 is displayed as @cite{18:6}. Note that the
format @samp{:1} writes fractions the same as @samp{:}, but it writes
integers as @cite{n:1}.
X
The fraction format does not affect the way fractions or integers are
stored, only the way they appear on the screen. The fraction format
never affects floats.
X
@node HMS Formats, Date Formats, Fraction Formats, Display Modes
@subsection HMS Formats
X
@noindent
@kindex d h
@pindex calc-hms-notation
The @kbd{d h} (@code{calc-hms-notation}) command controls the display of
HMS (hours-minutes-seconds) forms. It prompts for a string which
consists basically of an ``hours'' marker, optional punctuation, a
``minutes'' marker, more optional punctuation, and a ``seconds'' marker.
Punctuation is zero or more spaces, commas, or semicolons. The hours
marker is one or more non-punctuation characters. The minutes and
seconds markers must be single non-punctuation characters.
X
The default HMS format is @samp{@@ ' "}, producing HMS values of the form
@samp{23@@ 30' 15.75"}. The format @samp{deg, ms} would display this same
value as @samp{23deg, 30m15.75s}. During numeric entry, the @kbd{h} or @kbd{o}
keys are recognized as synonyms for @kbd{@@} regardless of display format.
The @kbd{m} and @kbd{s} keys are recognized as synonyms for @kbd{'} and
@kbd{"}, respectively, but only if an @kbd{@@} (or @kbd{h} or @kbd{o}) has
already been typed; otherwise, they have their usual meanings
(@kbd{m-} prefix and @kbd{s-} prefix). Thus, @kbd{5 "}, @kbd{0 @@ 5 "}, and
@kbd{0 h 5 s} are some of the ways to enter the quantity ``five seconds.''
The @kbd{'} key is recognized as ``minutes'' only if @kbd{@@} (or @kbd{h} or
@kbd{o}) has already been pressed; otherwise it means to switch to algebraic
entry.
X
@node Date Formats, Truncating the Stack, HMS Formats, Display Modes
@subsection Date Formats
X
@noindent
@kindex d d
@pindex calc-date-notation
The @kbd{d d} (@code{calc-date-notation}) command controls the display
of date forms (@pxref{Date Forms}). It prompts for a string which
contains letters that represent the various parts of a date and time.
To show which parts should be omitted when the form represents a pure
date with no time, parts of the string can be enclosed in @samp{< >}
marks. If you don't include @samp{< >} markers in the format, Calc
guesses at which parts, if any, should be omitted when formatting
pure dates.
X
The default format is: @samp{<H:mm:SSpp >Www Mmm D, YYYY}.
An example string in this format is @samp{3:32pm Wed Jan 9, 1991}.
If you enter a blank format string, this default format is
reestablished.
X
Calc uses @samp{< >} notation for nameless functions as well as for
dates. @xref{Specifying Operators}. To avoid confusion with nameless
functions, your date formats should avoid using the @samp{#} character.
X
@menu
* Date Formatting Codes::
* Free-Form Dates::
* Standard Date Formats::
@end menu
X
@node Date Formatting Codes, Free-Form Dates, Date Formats, Date Formats
@subsubsection Date Formatting Codes
X
@noindent
When displaying a date, the current date format is used. All
characters except for letters and @samp{<} and @samp{>} are
copied literally when dates are formatted. The portion between
@samp{< >} markers is omitted for pure dates, or included for
date/time forms. Letters are interpreted according to the table
below.
X
When dates are read in during algebraic entry, Calc first tries to
match the input string to the current format either with or without
the time part. The punctuation characters (including spaces) must
match exactly; letter fields must correspond to suitable text in
the input. If this doesn't work, Calc checks if the input is a
simple number; if so, the number is interpreted as a number of days
since Jan 1, 1 AD. Otherwise, Calc tries a much more relaxed and
flexible algorithm which is described in the next section.
X
Weekday names are ignored during reading.
X
Two-digit year numbers are interpreted as lying in the range
from 1941 to 2039. Years outside that range are always
entered and displayed in full. Year numbers with a leading
@samp{+} sign are always interpreted exactly, allowing the
entry and display of the years 1 through 99 AD.
X
Here is a complete list of the formatting codes for dates:
X
@table @asis
@item Y
Year: ``91'' for 1991, ``7'' for 2007, ``+23'' for 23 AD.
@item YY
Year: ``91'' for 1991, ``07'' for 2007, ``+23'' for 23 AD.
@item BY
Year: ``91'' for 1991, `` 7'' for 2007, ``+23'' for 23 AD.
@item YYY
Year: ``1991'' for 1991, ``23'' for 23 AD.
@item YYYY
Year: ``1991'' for 1991, ``+23'' for 23 AD.
@item aa
Year: ``ad'' or ``''.
@item AA
Year: ``AD'' or ``''.
@item aaa
Year: ``ad '' or ``''. (Note trailing space.)
@item AAA
Year: ``AD '' or ``''.
@item aaaa
Year: ``a.d.'' or ``''.
@item AAAA
Year: ``A.D.'' or ``''.
@item bb
Year: ``bc'' or ``''.
@item BB
Year: ``BC'' or ``''.
@item bbb
Year: `` bc'' or ``''. (Note leading space.)
@item BBB
Year: `` BC'' or ``''.
@item bbbb
Year: ``b.c.'' or ``''.
@item BBBB
Year: ``B.C.'' or ``''.
@item M
Month: ``8'' for August.
@item MM
Month: ``08'' for August.
@item BM
Month: `` 8'' for August.
@item MMM
Month: ``AUG'' for August.
@item Mmm
Month: ``Aug'' for August.
@item MMMM
Month: ``AUGUST'' for August.
@item Mmmm
Month: ``August'' for August.
@item D
Day: ``7'' for 7th day of month.
@item DD
Day: ``07'' for 7th day of month.
@item BD
Day: `` 7'' for 7th day of month.
@item W
Weekday: ``0'' for Sunday, ``6'' for Saturday.
@item WWW
Weekday: ``SUN'' for Sunday.
@item Www
Weekday: ``Sun'' for Sunday.
@item WWWW
Weekday: ``SUNDAY'' for Sunday.
@item Wwww
Weekday: ``Sunday'' for Sunday.
@item d
Day of year: ``34'' for Feb. 3.
@item ddd
Day of year: ``034'' for Feb. 3.
@item bdd
Day of year: `` 34'' for Feb. 3.
@item h
Hour: ``5'' for 5 AM; ``17'' for 5 PM.
@item hh
Hour: ``05'' for 5 AM; ``17'' for 5 PM.
@item bh
Hour: `` 5'' for 5 AM; ``17'' for 5 PM.
@item H
Hour: ``5'' for 5 AM and 5 PM.
@item HH
Hour: ``05'' for 5 AM and 5 PM.
@item BH
Hour: `` 5'' for 5 AM and 5 PM.
@item p
AM/PM: ``a'' or ``p''.
@item P
AM/PM: ``A'' or ``P''.
@item pp
AM/PM: ``am'' or ``pm''.
@item PP
AM/PM: ``AM'' or ``PM''.
@item pppp
AM/PM: ``a.m.'' or ``p.m.''.
@item PPPP
AM/PM: ``A.M.'' or ``P.M.''.
@item m
Minutes: ``7'' for 7.
@item mm
Minutes: ``07'' for 7.
@item bm
Minutes: `` 7'' for 7.
@item s
Seconds: ``7'' for 7; ``7.23'' for 7.23.
@item ss
Seconds: ``07'' for 7; ``07.23'' for 7.23.
@item bs
Seconds: `` 7'' for 7; `` 7.23'' for 7.23.
@item SS
Optional seconds: ``07'' for 7; blank for 0.
@item BS
Optional seconds: `` 7'' for 7; blank for 0.
@item N
Numeric date/time: ``726842.25'' for 6:00am Wed Jan 9, 1991.
@item n
Numeric date: ``726842'' for any time on Wed Jan 9, 1991.
@item J
Julian date/time: ``2448265.75'' for 6:00am Wed Jan 9, 1991.
@item j
Julian date: ``2448266'' for any time on Wed Jan 9, 1991.
@item U
Unix time: ``663400800'' for 6:00am Wed Jan 9, 1991.
@item X
Brackets suppression. An ``X'' at the front of the format
causes the surrounding @samp{< >} delimiters to be omitted
when formatting dates. Note that the brackets are still
required for algebraic entry.
@end table
X
If ``SS'' or ``BS'' (optional seconds) is preceded by a colon, the
colon is also omitted if the seconds part is zero.
X
If ``bb,'' ``bbb'' or ``bbbb'' or their upper-case equivalents
appear in the format, then negative year numbers are displayed
without a minus sign. Note that ``aa'' and ``bb'' are mutually
exclusive. Some typical usages would be @samp{YYYY AABB};
@samp{AAAYYYYBBB}; @samp{YYYYBBB}.
X
The formats ``YY,'' ``YYYY,'' ``MM,'' ``DD,'' ``ddd,'' ``hh,'' ``HH,''
``mm,'' ``ss,'' and ``SS'' actually match any number of digits during
reading unless several of them are strung together with no punctuation
in between, in which case the input must have exactly as many digits as
there are letters in the format.
X
The ``j,'' ``J,'' and ``U'' formats do not make any time zone
adjustment. They effectively use @samp{julian(x,0)} and
@samp{unixtime(x,0)} to make the conversion; @pxref{Date Arithmetic}.
X
@node Free-Form Dates, Standard Date Formats, Date Formatting Codes, Date Formats
@subsubsection Free-Form Dates
X
@noindent
When reading a date form during algebraic entry, Calc falls back
on the algorithm described here if the input does not exactly
match the current date format. This algorithm generally
``does the right thing'' and you don't have to worry about it,
but it is described here in full detail for the curious.
X
Calc does not distinguish between upper- and lower-case letters
while interpreting dates.
X
First, the time portion, if present, is located somewhere in the
text and then removed. The remaining text is then interpreted as
the date.
X
A time is of the form @samp{hh:mm:ss}, possibly with the seconds
part omitted and possibly with an AM/PM indicator added to indicate
12-hour time. If the AM/PM is present, the minutes may also be
omitted. The AM/PM part may be any of the words @samp{am},
@samp{pm}, @samp{noon}, or @samp{midnight}; each of these may be
abbreviated to one letter, and the alternate forms @samp{a.m.},
@samp{p.m.}, and @samp{mid} are also understood. Obviously
@samp{noon} and @samp{midnight} are allowed only on 12:00:00.
The words @samp{noon}, @samp{mid}, and @samp{midnight} are also
recognized with no number attached.
X
If there is no AM/PM indicator, the time is interpreted in 24-hour
format.
X
To read the date portion, all words and numbers are isolated
from the string; other characters are ignored. All words must
be either month names or day-of-week names (the latter of which
are ignored). Names can be written in full or as three-letter
abbreviations.
X
Large numbers, or numbers with @samp{+} or @samp{-} signs,
are interpreted as years. If one of the other numbers is
greater than 12, then that must be the day and the remaining
number in the input is therefore the month. Otherwise, Calc
assumes the month, day and year are in the same order that they
appear in the current date format. If the year is omitted, the
current year is taken from the system clock.
X
If there are too many or too few numbers, or any unrecognizable
words, then the input is rejected.
X
If there are any large numbers (of five digits or more) other than
the year, they are ignored on the assumption that they are something
like Julian dates that were included along with the traditional
date components when the date was formatted.
X
One of the words @samp{ad}, @samp{a.d.}, @samp{bc}, or @samp{b.c.}
may optionally be used; the latter two are equivalent to a
minus sign on the year value.
X
If you always enter a four-digit year, and use a name instead
of a number for the month, there is no danger of ambiguity.
X
@node Standard Date Formats, , Free-Form Dates, Date Formats
@subsubsection Standard Date Formats
X
@noindent
There are actually ten standard date formats, numbered 0 through 9.
Entering a blank line at the @kbd{d d} command's prompt gives
you format number 1, Calc's usual format. You can enter any digit
to select the other formats.
X
To create your own standard date formats, give a numeric prefix
argument from 0 to 9 to the @kbd{d d} command. The format you
enter will be recorded as the new standard format of that
number, as well as becoming the new current date format.
You can save your formats permanently with the @kbd{m m}
command (@pxref{Mode Settings}).
X
@table @asis
@item 0
@samp{N} (Numerical format)
@item 1
@samp{<H:mm:SSpp >Www Mmm D, YYYY} (American format)
@item 2
@samp{D Mmm YYYY<, h:mm:SS>} (European format)
@item 3
@samp{Www Mmm BD< hh:mm:ss> YYYY} (Unix written date format)
@item 4
@samp{M/D/Y< H:mm:SSpp>} (American slashed format)
@item 5
@samp{D.M.Y< h:mm:SS>} (European dotted format)
@item 6
@samp{M-D-Y< H:mm:SSpp>} (American dashed format)
@item 7
@samp{D-M-Y< h:mm:SS>} (European dashed format)
@item 8
@samp{j<, h:mm:ss>} (Julian day plus time)
@item 9
@samp{YYddd< hh:mm:ss>} (Year-day format)
@end table
X
@node Truncating the Stack, Justification, Date Formats, Display Modes
@subsection Truncating the Stack
X
@noindent
@kindex d t
@pindex calc-truncate-stack
@cindex Truncating the stack
@cindex Narrowing the stack
The @kbd{d t} (@code{calc-truncate-stack}) command moves the @samp{.}@:
line that marks the top-of-stack up or down in the Calculator buffer.
The number right above that line is considered to the be at the top of
the stack. Any numbers below that line are ``hidden'' from all stack
operations. This is similar to the Emacs ``narrowing'' feature, except
that the values below the @samp{.} are @emph{visible}, just temporarily
frozen. This feature allows you to keep several independent calculations
running at once in different parts of the stack, or to apply a certain
command to an element buried deep in the stack.@refill
X
Pressing @kbd{d t} by itself moves the @samp{.} to the line the cursor
is on. Thus, this line and all those below it become hidden. To un-hide
these lines, move down to the end of the buffer and press @kbd{d t}.
With a positive numeric prefix argument @cite{n}, @kbd{d t} hides the
bottom @cite{n} values in the buffer. With a negative argument, it hides
all but the top @cite{n} values. With an argument of zero, it hides zero
values, i.e., moves the @samp{.} all the way down to the bottom.@refill
X
@kindex d [
@pindex calc-truncate-up
@kindex d ]
@pindex calc-truncate-down
The @kbd{d [} (@code{calc-truncate-up}) and @kbd{d ]}
(@code{calc-truncate-down}) commands move the @samp{.} up or down one
line at a time (or several lines with a prefix argument).@refill
X
@node Justification, Labels, Truncating the Stack, Display Modes
@subsection Justification
X
@noindent
@kindex d <
@pindex calc-left-justify
@kindex d =
@pindex calc-center-justify
@kindex d >
@pindex calc-right-justify
Values on the stack are normally left-justified in the window. You can
control this arrangement by typing @kbd{d <} (@code{calc-left-justify}),
@kbd{d >} (@code{calc-right-justify}), or @kbd{d =}
(@code{calc-center-justify}). For example, in right-justification mode,
stack entries are displayed flush-right against the right edge of the
window.@refill
X
If you change the width of the Calculator window you may have to type
@kbd{d SPC} (@code{calc-refresh}) to re-align right-justified or centered
text.
X
Right-justification is especially useful together with fixed-point
notation (see @code{d f}; @code{calc-fix-notation}). With these modes
together, the decimal points on numbers will always line up.
X
With a numeric prefix argument, the justification commands give you
a little extra control over the display. The argument specifies the
horizontal ``origin'' of a display line. It is also possible to
specify a maximum line width using the @kbd{d b} command (@pxref{Normal
Language Modes}). For reference, the precise rules for formatting and
breaking lines are given below. Notice that the interaction between
origin and line width is slightly different in each justification
mode.
X
In left-justified mode, the line is indented by a number of spaces
given by the origin (default zero). If the result is longer than the
maximum line width, if given, or too wide to fit in the Calc window
otherwise, then it is broken into lines which will fit; each broken
line is indented to the origin.
X
In right-justified mode, lines are shifted right so that the rightmost
character is just before the origin, or just before the current
window width if no origin was specified. If the line is too long
for this, then it is broken; the current line width is used, if
specified, or else the origin is used as a width if that is
specified, or else the line is broken to fit in the Calc window.
X
In centering mode, the origin is the column number of the center of
each stack entry. If a line width is specified, lines will not be
allowed to go past that width; Calc will either indent less or
break the lines if necessary. If no origin is specified, half the
line width or Calc window width is used.
X
Note that, in each case, if line numbering is enabled the display
is indented an additional four spaces to make room for the line
number. The width of the line number is taken into account when
positioning according to the current Calc window width, but not
when positioning by explicit origins and widths. In the latter
case, the display is formatted as specified, and then uniformly
shifted over four spaces to fit the line numbers.
X
@node Labels, , Justification, Display Modes
@subsection Labels
X
@noindent
@kindex d @{
@pindex calc-left-label
@kindex d @}
@pindex calc-right-label
The @kbd{d @{} (@code{calc-left-label}) command prompts for a string,
then displays that string to the left of every stack entry. If the
entries are left-justified (@pxref{Justification}), then they will
appear immediately after the label (unless you specified an origin
greater than the length of the label). If the entries are centered
or right-justified, the label appears on the far left and does not
affect the horizontal position of the stack entry.
X
Give a blank string (with @kbd{d @{ @key{RET}}) to turn the label off.
X
The @kbd{d @}} (@code{calc-right-label}) command similarly adds a
label on the righthand side. It does not affect positioning of
the stack entries unless they are right-justified. Also, if both
a line width and an origin are given in right-justified mode, the
stack entry is justified to the origin and the righthand label is
justified to the line width.
X
One application of labels would be to add equation numbers to
formulas you are manipulating in Calc and then copying into a
document (possibly using Embedded Mode). The equations would
typically be centered, and the equation numbers would be on the
left or right as you prefer.
X
@node Language Modes, Calc Mode Line, Display Modes, Mode Settings
@section Language Modes
X
@noindent
The commands in this section change Calc to use a different notation for
entry and display of formulas, corresponding to the conventions of some
other common language such as Pascal or @TeX{}. Objects displayed on the
stack or yanked from the Calculator to an editing buffer will be formatted
in the current language; objects entered in algebraic entry or yanked from
another buffer will be interpreted according to the current language.
X
The current language has no effect on things written to or read from the
trail buffer, nor does it affect numeric entry. Only algebraic entry is
affected. You can make even algebraic entry ignore the current language
and use the standard notation by giving a numeric prefix, e.g., @kbd{C-u '}.
X
For example, suppose the formula @samp{2*a[1] + atan(a[2])} occurs in a C
program; elsewhere in the program you need the derivatives of this formula
with respect to @samp{a[1]} and @samp{a[2]}. First, type @kbd{d C}
to switch to C notation. Now use @code{C-u M-# g} to grab the formula
into the Calculator, @kbd{a d a[1] @key{RET}} to differentiate with respect
to the first variable, and @kbd{M-# y} to yank the formula for the derivative
back into your C program. Press @kbd{U} to undo the differentiation and
repeat with @kbd{a d a[2] @key{RET}} for the other derivative.
X
Without being switched into C mode first, Calc would have misinterpreted
the brackets in @samp{a[1]} and @samp{a[2]}, would not have known that
@code{atan} was equivalent to Calc's built-in @code{arctan} function,
and would have written the formula back with notations (like implicit
multiplication) which would not have been legal for a C program.
X
As another example, suppose you are maintaining a C program and a @TeX{}
document, each of which needs a copy of the same formula. You can grab the
formula from the program in C mode, switch to @TeX{} mode, and yank the
formula into the document in @TeX{} math-mode format.
X
Language modes are selected by typing the letter @kbd{d} followed by a
shifted letter key.
X
@menu
* Normal Language Modes::
* C FORTRAN Pascal::
* TeX Language Mode::
* Eqn Language Mode::
* Mathematica Language Mode::
* Maple Language Mode::
* Compositions::
@end menu
X
@node Normal Language Modes, C FORTRAN Pascal, Language Modes, Language Modes
@subsection Normal Language Modes
X
@noindent
@kindex d N
@pindex calc-normal-language
The @kbd{d N} (@code{calc-normal-language}) command selects the usual
notation for Calc formulas, as described in the rest of this manual.
Matrices are displayed in a multi-line tabular format, but all other
objects are written in linear form, as they would be typed from the
keyboard.
X
@kindex d O
@pindex calc-flat-language
@cindex Matrix display
The @kbd{d O} (@code{calc-flat-language}) command selects a language
identical with the normal one, except that matrices are written in
one-line form along with everything else. In some applications this
form may be more suitable for yanking data into other buffers.
X
@kindex d b
@pindex calc-line-breaking
@cindex Line breaking
@cindex Breaking up long lines
Even in one-line mode, long formulas or vectors will still be split
across multiple lines if they exceed the width of the Calculator window.
SHAR_EOF
true || echo 'restore of calc.texinfo failed'
fi
echo 'End of part 39'
echo 'File calc.texinfo is continued in part 40'
echo 40 > _shar_seq_.tmp
exit 0
exit 0 # Just in case...
--
Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD UUCP: uunet!sparky!kent
Phone: (402) 291-8300 FAX: (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.