.\" Man page for spar - text front end .\" .\" Spar - a text front end for the Spar library .\" Copyright (C) 2000,2001 Davide Angelocola .\" .\" This program is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by .\" the Free Software Foundation; either version 2 of the License, or .\" (at your option) any later version. .\" .\" This program is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public License .\" along with this program; if not, write to the Free Software .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA .\" .\" TO-DO: USING THE SPAR LIBRARY .TH SPAR 1 "26 Jun 2001" .rn RS Rs .de RS .na .nf .Rs .. .rn RE Re .de RE .Re .fi .ad .. .de Sx .PP .ne \\$1 .RS .. .de Ex .RE .PP .. .na .SH NAME spar \- a modular console calculator .SH SYNOPSIS .nf spar [options] [\-\-] expression .fi .SH DESCRIPTION \fBSpar\fR is a console calculator, primarily intended for problem solving in arbitrary precision. It supports also modules (aka code that can be loaded dynamically) and a number of other features, such as: user variables, functions, and constants. .SS OPTIONS .TP 4 .TP .B -d\fR, \fB--decimals\fR Set the decimal precision (number of digits printed \fBafter\fR the point). .TP .B -i\fR, \fB--integers\fR Set the integer precision (number of digits printed \fBbefore\fR the point). .TP .B -c\fR, \fB--config\fR Use a user-defined modules configuration file. .TP .B -q\fR, \fB--quiet\fR Don't display the welcome message. .TP .B -h\fR, \fB--help\fR Display usage information and exit. .TP .B -v\fR, \fB--version\fR Print version information and exit. .TP .B --\fR Terminate option list: now all arguments is interpreted as an expression to evaluate. .SH NUMBERS The most basic element in \fBspar\fR is the number. Numbers are double precision numbers. All numbers are represented internally as a standard C double variable. There are no attributes of numbers, but the precision can affect the number output. This precision is both in the integer part and the decimal part. .PP For example: The number 0.123456789 is represented internally as a double precision variable, but if we change the precision, the output will change: 0.123456789 = 0.123457 .SH VARIABLES Numbers can be stored in named variables. Variable names begin with a letter followed by any number of letters, digits and underscores. The variable names are case sensitive. Variables may have values assigned to them as well as used in expressions and it contains a special data member that stores the "previous" value". .PP To declare a variable you must supply both a name and a value. Any undeclared variable generate an error. For example, to declare the variable i of value 5 enter: .nf .RS i = 5 .RE .fi .SH CONSTANTS Constants are special variables that is read-only. This means that you can read a constant value but you can modify. There is a number of "preloaded" variables such as "e", "pi" ecc. .SH FUNCTIONS \fBspar\fR support a number of often used scientific functions (directly from \fBThe Spar Library\fR). For example, to get the value of the natural logarithm in 0 enter: .nf .RS log(0) .RE .fi .SS Trig Functions These are the familiar `sin', `cos', and `tan' functions. The arguments to all of these functions are in units of radians; recall that pi radians equals 180 degrees. .SS Inverse Trig Functions These are the usual arc sine, arc cosine and arc tangent functions, which are the inverses of the sine, cosine and tangent functions respectively. .SS Exponents and Logarithms These are the 'exp' group, 'log' group, 'pow' group and 'sqrt' group. .SS Hyperbolic Functions sinh, cosh, tanh. The functions in this section are related to the exponential functions. .SS Inverse Hyperbolic Functions asinh, acosh, atanh. The functions in this section are related to the Hyperbolicfunctions. .SS Infinite Functions isnan, finite, isinf. .SS Special Functions Factorial, sum, and other specific \fBspar\fR functions. .SH EXPRESSIONS The numbers are manipulated by expressions and statements. Since the math parser was implemented to be interactive, statements and expressions are executed as soon as possible. .PP A simple expression is just a constant. \fBspar\fR displays constants using the current precision (see OPTIONS). Full expressions are similar to many other high level languages. Since there is only one kind of number, there are no rules for mixing types. .PP In the following descriptions of legal expressions, "expr" refers to a complete expression and "var" refers to a simple variable. .PP .IP "- expr" The result is the negation of the expression. .IP "expr + expr" The result of the expression is the sum of the two expressions. .IP "expr - expr" The result of the expression is the difference of the two expressions. .IP "expr * expr" The result of the expression is the product of the two expressions. .IP "expr / expr" The result of the expression is the quotient of the two expressions. .IP "expr % expr" The result of the expression is the "remainder" and it is computed in the following way. .IP "expr ^ expr" The result of the expression is the value of the first raised to the second. .IP "( expr )" This alters the standard precedence to force the evaluation of the expression. .IP "var = expr" The variable is assigned the value of the expression. .IP "var" This prints variable value's: note that "var" could be also a constant. .SH COMMANDS .IP "\fBhelp\fR" Print a brief commands notice. If a command name is supplied print a detailed command report. .IP "\fBwarranty\fR" Print a longer warranty notice. No arguments. .IP "\fBcomment\fR" Add a comment to a variable. At least two arguments. .IP "\fBconsts\fR" Print the built-in constants table. No arguments. .IP "\fBfuncs\fR" Print the built-in functions table. No arguments. .IP "\fBmodules\fR" Print the all loaded modules. No arguments. .IP "\fBold\fR" Swap the current variable value with the old one. One argument. .IP "\fBquit\fR" Program termination. .IP "\fBrun\fR" Run a module. Note that you must supply a valid module name otherwise, the list of the loaded modules is printed. .IP "\fBvars\fR" Print all user variables. .SH FEATURES Spar supports terminal features (termios) to allow the program to be more user-friendly and also more robust. .SS READLINE OPTION \fBSpar\fR can be compiled (via configure script) to use the GNU \fBreadline\fR input editor library. This allows the user to do more editing of lines before sending them to \fBspar\fR. .PP READLINE SPECIAL KEYS It also allows for a history of previous lines typed: the history can be viewed by '\' key, whereas the readline auto-completion was implemented by the TAB key. For more information, read the user manuals for the GNU \fBreadline\fR and \fBhistory\fR libraries. Instead the key '!' run the last command and, finally the key ':' can be used to display a specific history item. For example: ':1' shows the first history item. .SS SIGNALS SUPPORT During a session, the SIGINT signal (usually generated by the control-C character from the terminal), SIGSTP signal (usually generated by the control-Z character from the terminal) and SIGTERM signal will cause execution to be interrupted. After all run-time structures have been cleaned up, a message will be printed to notify the user that \fBspar\fR is aborted. All variables and modules are removed during the clean up process. .SS TERMCAP SUPPORT The control key EOF is inhibited. \fBspar\fR restore this setting on exit. .SH BUGS The best way to submit a bug report for Spar is to use the file BUG-REPORT, that will enable me to fix the problem. Please visit the Spar homepages at: .nf http://spar.sourceforge.net/index.html (main site) http://web.tiscalinet.it/Davide18/index.html .fi for the latest version, patches and documentation. .SH FILES .nf /usr/local/bin/spar Spar /usr/local/lib/libspar.so Spar Library /usr/local/include/spar/* Spar Headers /usr/local/lib/spar/* Spar modules /usr/local/share/spar/modules_config Spar modules config .fi .SH AUTHOR .br Davide Angelocola davide178@inwind.it .fi .SH ACKNOWLEDGMENTS The author would like to thank Sebastian Ritterbusch (Rascal@Ritterbusch.de) for his extensive help in testing the program and the documentation. Many great suggestions were given. Please visit his website http://rascal.sourceforge.net or the sourceforge project at http://sourceforge.net/projects/rascal. .SH SEE ALSO .nf \fBbc(1)\fP An arbitrary precision calculator language .fi Spar can be used also as library, a API reference can be founded via web at http://sourceforge.net/projects/spar. Please help me to extend and correct it.