summaryrefslogtreecommitdiff
path: root/doc/bc.texi
diff options
context:
space:
mode:
Diffstat (limited to 'doc/bc.texi')
-rw-r--r--doc/bc.texi91
1 files changed, 63 insertions, 28 deletions
diff --git a/doc/bc.texi b/doc/bc.texi
index a7cb9f6..d6162b6 100644
--- a/doc/bc.texi
+++ b/doc/bc.texi
@@ -4,6 +4,8 @@
@settitle bc Command Manual
@c %**end of header
+@include texi-ver.incl
+
@c This file has the new style title page commands.
@c Run `makeinfo' rather than `texinfo-format-buffer'.
@@ -13,10 +15,16 @@
@c \overfullrule=0pt
@c end tex
+@ifinfo
+@direntry
+* bc: (bc). An arbitrary precision calculator language.
+@end direntry
+@end ifinfo
+
@titlepage
@title @command{bc}
@subtitle an arbitrary precision calculator language
-@subtitle version 1.06
+@subtitle version @value{BC_VERSION}
@author Philip A. Nelson
@page
@@ -24,20 +32,20 @@
This manual documents @command{bc}, an arbitrary precision calculator language.
This manual is part of GNU @command{bc}.@*
-@sp4
-Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
-59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+@sp 4
+Copyright (C) 1991, 1992, 1993, 1994, 1997, 2003, 2006 Free Software Foundation, Inc.
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
-@iftex
+@ignore
Permission is granted to process this file through TeX and print the
results, provided the printed document carries copying permission
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).
-@end iftex
+@end ignore
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
@@ -68,7 +76,7 @@ Bellingham, WA 98226-9062
* Functions::
* Examples::
* Readline and Libedit Options::
-* GNU @command{bc} and Other Implementations::
+* Comparison with Other Implementations::
* Limits::
* Environment Variables::
@end menu
@@ -613,12 +621,12 @@ A function call is just an expression of the form
Parameters are numbers or arrays (an extension). In the function definition,
zero or more parameters are defined by listing their names separated by
-commas. Numbers are only call by value parameters. Arrays are only
-call by variable. Arrays are specified in the parameter definition by
+commas. All parameters are call by value parameters.
+Arrays are specified in the parameter definition by
the notation "@var{name}@code{[ ]}". In the function call, actual parameters
are full expressions for number parameters. The same notation is used
for passing arrays as for defining array parameters. The named array is
-passed by variable to the function. Since function definitions are dynamic,
+passed by value to the function. Since function definitions are dynamic,
parameter numbers and types are checked when a function is called. Any
mismatch in number or types of parameters will cause a runtime error.
A runtime error will also occur for the call to an undefined function.
@@ -658,12 +666,12 @@ will be ignored during the execution of the function except for the
standard function @code{read}, which will always use the current value
of @var{ibase} for conversion of numbers.
-As an extension, the format of the definition has been slightly relaxed.
-The standard requires the opening brace be on the same line as the
-@code{define} keyword and all other parts must be on following lines.
-This version of @command{bc} will allow any number of newlines before and
-after the opening brace of the function. For example, the following
-definitions are legal.
+Several extensions have been added to functions. First, the format of
+the definition has been slightly relaxed. The standard requires the
+opening brace be on the same line as the @code{define} keyword and all
+other parts must be on following lines. This version of @command{bc}
+will allow any number of newlines before and after the opening brace of
+the function. For example, the following definitions are legal.
@example
define d (n) @{ return (2*n); @}
@@ -671,6 +679,33 @@ definitions are legal.
@{ return (2*n); @}
@end example
+Functions may be defined as @code{void}. A void
+funtion returns no value and thus may not be used in any place that needs
+a value. A void function does not produce any output when called by itself
+on an input line. The key word @code{void} is placed between the key word
+@code{define} and the function name. For example, consider the following
+session.
+
+@example
+define py (y) @{ print "--->", y, "<---", "\n"; @}
+define void px (x) @{ print "--->", x, "<---", "\n"; @}
+py(1)
+--->1<---
+0
+px(1)
+--->1<---
+@end example
+
+Since @code{py} is not a void function, the call of @code{py(1)} prints
+the desired output and then prints a second line that is the value of
+the function. Since the value of a function that is not given an
+explicit return statement is zero, the zero is printed. For @code{px(1)},
+no zero is printed because the function is a void function.
+
+Also, call by variable for arrays was added. To declare a
+call by variable array, the declaration of the array parameter in the
+function definition looks like "@code{*}@var{name}@code{[]}". The call
+to the function remains the same as call by value arrays.
@node Math Library Functions, , Functions, Functions
@section Math Library Functions
@@ -693,11 +728,11 @@ The arctangent of @var{x}, arctangent returns radians.
@item l (@var{x})
The natural logarithm of @var{x}.
-@item @var{e} (@var{x})
+@item e (@var{x})
The exponential function of raising @var{e} to the value @var{x}.
-@item @var{j} (@var{n,x})
-The bessel function of integer order @var{n} of @var{x}.
+@item j (@var{n,x})
+The Bessel function of integer order @var{n} of @var{x}.
@end table
@node Examples, Readline and Libedit Options, Functions, Top
@@ -797,7 +832,7 @@ define f (x) @{
@end example
-@node Readline and Libedit Options, GNU @command{bc} and Other Implementations, Examples, Top
+@node Readline and Libedit Options, Comparison with Other Implementations, Examples, Top
@chapter Readline and Libedit Options
GNU @command{bc} can be compiled (via a configure option) to use the GNU
@@ -815,8 +850,8 @@ more information, read the user manuals for the GNU @command{readline},
@command{history} and BSD @command{libedit} libraries. One can not
enable both @command{readline} and @command{libedit} at the same time.
-@node GNU @command{bc} and Other Implementations, Limits, Readline and Libedit Options, Top
-@chapter GNU @command{bc} and Other Implementations
+@node Comparison with Other Implementations, Limits, Readline and Libedit Options, Top
+@chapter Comparison with Other Implementations
This version of @command{bc} was implemented from the POSIX P1003.2/D11
draft and contains several differences and extensions relative to the
@@ -943,7 +978,7 @@ non-interactive session, the SIGINT signal will terminate the entire run
of @command{bc}.
@end table
-@node Limits, Environment Variables, GNU @command{bc} and Other Implementations, Top
+@node Limits, Environment Variables, Comparison with Other Implementations, Top
@chapter Limits
The following are the limits currently in place for this @command{bc}
@@ -995,7 +1030,7 @@ This is the same as the -s option (@pxref{Command Line Options}).
@item BC_ENV_ARGS
This is another mechanism to get arguments to @command{bc}. The format
is the same as the command line arguments. These arguments are
-processed first, so any files listed in the environent arguments are
+processed first, so any files listed in the environment arguments are
processed before any command line argument files. This allows the user
to set up "standard" options and files to be processed at every
invocation of @command{bc}. The files in the environment variables
@@ -1003,12 +1038,12 @@ would typically contain function definitions for functions the user
wants defined every time @command{bc} is run.
@item BC_LINE_LENGTH
-This should be an integer specifing the number of characters in an
+This should be an integer specifying the number of characters in an
output line for numbers. This includes the backslash and newline
-characters for long numbers.
+characters for long numbers. As an extension, the value of zero disables the
+multi-line feature. Any other value of this variable that is less than
+3 sets the line length to 70.
@end table
@contents
@bye
-
-