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

GNU Emacs Calc 2.02 Manual

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

Normally all input and output for calc-eval is done with strings. You can do arithmetic with, say, `(calc-eval "$+$$" nil a b)' in place of `(+ a b)', but this is very inefficient since the numbers must be converted to and from string format as they are passed from one calc-eval to the next.

If the separator is the symbol raw, the result will be returned as a raw Calc data structure rather than a string. You can read about how these objects look in the following sections, but usually you can treat them as "black box" objects with no important internal structure.

There is also a rawnum symbol, which is a combination of raw (returning a raw Calc object) and num (signalling an error if that object is not a constant).

You can pass a raw Calc object to calc-eval in place of a string, either as the formula itself or as one of the `$' arguments. Thus `(calc-eval "$+$$" 'raw a b)' is an addition function that operates on raw Calc objects. Of course in this case it would be easier to call the low-level math-add function in Calc, if you can remember its name.

In particular, note that a plain Lisp integer is acceptable to Calc as a raw object. (All Lisp integers are accepted on input, but integers of more than six decimal digits are converted to "big-integer" form for output. See section Data Type Formats.)

When it comes time to display the object, just use `(calc-eval a)' to format it as a string.

It is an error if the input expression evaluates to a list of values. The separator symbol list is like raw except that it returns a list of one or more raw Calc objects.

Note that a Lisp string is not a valid Calc object, nor is a list containing a string. Thus you can still safely distinguish all the various kinds of error returns discussed above.


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

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