For questions regarding this package, please send e-mail to consult@acm.rpi.edu (The ACM Consulting Group).

**The following info is available:**

This is the second official release of calc (version 2.9.0). Calc is an arbitrary precision C-like programmable calculator with many builtin functions. The basic data types are integers, fractions, complex numbers, strings, matrices, associations, lists, files, and user-definable "objects". You can use it interactively to evaluate expressions line by line, or else you can write complicated programs in it's C-like language. There are many features which I will not bother to describe here. Calc is written entirely in C, and runs on many different platforms and variants of UNIX. The low-level arbitrary precision math routines have been organized into three libraries for handling integers, fractions, and complex numbers. You can call the routines in these libraries from your own C programs. The sources in this posting are also available by anonymous ftp from ftp.uu.net in the file pub/calc/calc2.9.0.tar.Z. The contents of the pub/calc directory are updated occasionally with the newest version. The calculator is copyrighted, but there are no restrictions on it other than the preservation of the copyright notices.

- calc

### NAME

**calc**- arbitrary precision calculator### SYNOPSIS

**calc**[**-h**] [**-q**] [*calc_cmd*... ]### DESCRIPTION

CALC COMMAND LINE

**-h**Print a help message. This option implies**-q**. This is equivalent to the calc command**help****help**.**-q**Disable the use of the**$CALCRC**startup library scripts. Without**calc_cmd**s,**calc**operates interactively. If one or more**calc_cmd**s are given on the command line,**calc**will execute them and exit. Normally on startup,**calc**attempts to execute a collection of library scripts. The environment variable**$CALCRC**(if non-existent then a compiled in value) contains a**:**separated list of startup library scripts. No error conditions are produced if these startup library scripts are not found. Filenames are subject to ``~'' expansion (see below). The environment variable**$CALCPATH**(if non-existent then a compiled in value) contains a**:**separated list of search directories. If a file does not begin with**/**,**~**or**./**, then it is searched for under each directory listed in the**$CALCPATH**. It is an error if no such readable file is found. For more information use the following calc commands: help usage help help help environment OVERVIEW**Calc**is arbitrary precision arithmetic system that uses a C-like language.**Calc**is useful as a calculator, an algorithm prototyped and as a mathematical research tool. More importantly,**calc**provides one with a machine independent means of computation.**Calc**comes with a rich set of builtin mathematical and programmatic functions.**Calc**is distributed with library of scripts. Written in the same C-like language, library scripts may be read in and executed during a**calc**session. These library scripts are also provided because they are useful and to serve as examples of the**calc**language. One may further extend**calc**thru the use of user defined scripts. Internally calc represents numeric values as fractions reduced to their lowest terms. The numerators and denominators of these factions may grow to arbitrarily large values. Numeric values read in are automatically converted into rationals. The user need not be aware of this internal representation. For more information use the following calc commands: help intro help builtin help stdlib help define show builtins show functions DATA TYPES Fundamental builtin data types include integers, real numbers, rational numbers, complex numbers and strings. By use of an object, one may define an arbitrarily complex data types. One may define how such objects behave a wide range of operations such as addition, subtraction, multiplication, division, negation, squaring, modulus, rounding, exponentiation, equality, comparison, printing and so on. For more information use the following calc commands: help types help obj show objfuncs VARIABLES Variables in**calc**are typeless. In other words, the fundamental type of a variable is determined by its content. Before a variable is assigned a value it has the value of zero. The scope of a variable may be global, local to a file, or local to a procedure. Values may be grouped together in a matrix, or into a a list that permits stack and queue style operations. For more information use the following calc commands: help variable help mat help list show globals INPUT/OUTPUT A leading ``0x'' implies a hexadecimal value, a leading ``0b'' implies a binary value, and a ``0'' followed by a digit implies an octal value. Complex numbers are indicated by a trailing ``i'' such as in ``3+4i''. Strings may be delimited by either a pair of single or double quotes. By default,**calc**prints values as if they were floating point numbers. One may change the default to print values in a number of modes including fractions, integers and exponentials. A number of stdio-like file I/O operations are provided. One may open, read, write, seek and close files. Filenames are subject to ``~'' expansion to home directories in a way similar to that of the Korn or C-Shell. For example: ~/.calcrc ~chongo/lib/fft_multiply.cal For more information use the following calc command: help file CALC LANGUAGE The**calc**language is a C-like language. The language includes commands such as variable declarations, expressions, tests, labels, loops, file operations, function calls. These commands are very similar to their counterparts in C. The language also include a number of commands particular to**calc**itself. These include commands such as function definition, help, reading in library scripts, dump files to a file, error notification, configuration control and status. For more information use the following calc command: help command help statement help expression help operator help config### FILES

/dept/acm/packages/calc/2.9.0/common/lib/*.cal library scripts shipped with calc /dept/acm/packages/calc/2.9.0/common/lib/help/* help files /dept/acm/packages/calc/2.9.0/common/lib/bindings command line editor bindings

### ENVIRONMENT

CALCPATH A :-separated list of directories used to search for scripts filenames that do not begin with /, ./ or ~. Default value: .:./lib:~/lib:/dept/acm/packages/calc/2.9.0/common/lib CALCRC On startup (unless -h or -q was given on the command line), calc searches for files along this :-separated environment variable. Default value: /dept/acm/packages/calc/2.9.0/common/lib/startup:~/.calcrc CALCBINDINGS On startup (unless -h or -q was given on the command line), calc reads key bindings from the filename specified by this environment variable. Default value: /dept/acm/packages/calc/2.9.0/common/lib/bindings

### CREDIT

Written by David I. Bell. Thanks for suggestions and encouragement from Peter Miller, Neil Justusson, and Landon Noll. Portions of this program are derived from an earlier set of public domain arbitrarily precision routines which was posted to the net around 1984. By now, there is almost no recognizable code left from that original source. Most of this source and binary is: Copyright (c) 1993 David I. Bell Some files are a copyrighted David I. Bell and Landon Noll. Permission is granted to use, distribute, or modify this source, provided that this copyright notice remains intact. Send calc comments, suggestions, bug fixes, enhancements and interesting calc scripts that you would like you see included in future distributions to: dbell@canb.auug.org.au chongo@toad.com Enjoy!