www.delorie.com/gnu/docs/calc/calc_176.html | search |
Buy the book! | |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The d C (calc-c-language
) command selects the conventions
of the C language for display and entry of formulas. This differs from
the normal language mode in a variety of (mostly minor) ways. In
particular, C language operators and operator precedences are used in
place of Calc's usual ones. For example, `a^b' means `xor(a,b)'
in C mode; a value raised to a power is written as a function call,
`pow(a,b)'.
In C mode, vectors and matrices use curly braces instead of brackets.
Octal and hexadecimal values are written with leading `0' or `0x'
rather than using the `#' symbol. Array subscripting is
translated into subscr
calls, so that `a[i]' in C
mode is the same as `a_i' in normal mode. Assignments
turn into the assign
function, which Calc normally displays
using the `:=' symbol.
The variables var-pi
and var-e
would be displayed `pi'
and `e' in normal mode, but in C mode they are displayed as
`M_PI' and `M_E', corresponding to the names of constants
typically provided in the `<math.h>' header. Functions whose
names are different in C are translated automatically for entry and
display purposes. For example, entering `asin(x)' will push the
formula `arcsin(x)' onto the stack; this formula will be displayed
as `asin(x)' as long as C mode is in effect.
The d P (calc-pascal-language
) command selects Pascal
conventions. Like C mode, Pascal mode interprets array brackets and uses
a different table of operators. Hexadecimal numbers are entered and
displayed with a preceding dollar sign. (Thus the regular meaning of
$2 during algebraic entry does not work in Pascal mode, though
$ (and $$, etc.) not followed by digits works the same as
always.) No special provisions are made for other non-decimal numbers,
vectors, and so on, since there is no universally accepted standard way
of handling these in Pascal.
The d F (calc-fortran-language
) command selects FORTRAN
conventions. Various function names are transformed into FORTRAN
equivalents. Vectors are written as `/1, 2, 3/', and may be
entered this way or using square brackets. Since FORTRAN uses round
parentheses for both function calls and array subscripts, Calc displays
both in the same way; `a(i)' is interpreted as a function call
upon reading, and subscripts must be entered as `subscr(a, i)'.
Also, if the variable a
has been declared to have type
vector
or matrix
then `a(i)' will be parsed as a
subscript. (See section 7.6 Declarations.) Usually it doesn't matter, though;
if you enter the subscript expression `a(i)' and Calc interprets
it as a function call, you'll never know the difference unless you
switch to another language mode or replace a
with an actual
vector (or unless a
happens to be the name of a built-in
function!).
Underscores are allowed in variable and function names in all of these language modes. The underscore here is equivalent to the `#' in normal mode, or to hyphens in the underlying Emacs Lisp variable names.
FORTRAN and Pascal modes normally do not adjust the case of letters in formulas. Most built-in Calc names use lower-case letters. If you use a positive numeric prefix argument with d P or d F, these modes will use upper-case letters exclusively for display, and will convert to lower-case on input. With a negative prefix, these modes convert to lower-case for display and input.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
webmaster donations bookstore | delorie software privacy |
Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |