mirror of https://gitee.com/openkylin/bc.git
Fix some formatting issues with bc man page
* Space at end of lines removed * Removed or added word space * Use "\(en" as a dash to indicate a range instead of "-" * Added "\&" after a full stop if it is not an end of sentence * Use "\e" to print a backslash * Use either macros "IR" or "RI" when mixing these two styles in a row of words * Use "\," when mixing roman and italic, "\/" for italic and roman. * The Word 'funtion' changed to 'function'. Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=725898 Forwarded: no Gbp-Pq: Name 07_bc_man.diff
This commit is contained in:
parent
1db65a601a
commit
db58bce935
107
doc/bc.1
107
doc/bc.1
|
@ -36,7 +36,7 @@ bc - An arbitrary precision calculator language
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
\fBbc\fR is a language that supports arbitrary precision numbers
|
\fBbc\fR is a language that supports arbitrary precision numbers
|
||||||
with interactive execution of statements. There are some similarities
|
with interactive execution of statements. There are some similarities
|
||||||
in the syntax to the C programming language.
|
in the syntax to the C programming language.
|
||||||
A standard math library is available by command line option.
|
A standard math library is available by command line option.
|
||||||
If requested, the math library is defined before processing any files.
|
If requested, the math library is defined before processing any files.
|
||||||
\fBbc\fR starts by processing code from all the files listed
|
\fBbc\fR starts by processing code from all the files listed
|
||||||
|
@ -47,8 +47,8 @@ processor, \fBbc\fR will never read from the standard input.)
|
||||||
.PP
|
.PP
|
||||||
This version of \fBbc\fR contains several extensions beyond
|
This version of \fBbc\fR contains several extensions beyond
|
||||||
traditional \fBbc\fR implementations and the POSIX draft standard.
|
traditional \fBbc\fR implementations and the POSIX draft standard.
|
||||||
Command line options can cause these extensions to print a warning
|
Command line options can cause these extensions to print a warning
|
||||||
or to be rejected. This
|
or to be rejected. This
|
||||||
document describes the language accepted by this processor.
|
document describes the language accepted by this processor.
|
||||||
Extensions will be identified as such.
|
Extensions will be identified as such.
|
||||||
.SS OPTIONS
|
.SS OPTIONS
|
||||||
|
@ -87,13 +87,13 @@ Numbers are stored in two types of variables, simple variables and
|
||||||
arrays. Both simple variables and array variables are named. Names
|
arrays. Both simple variables and array variables are named. Names
|
||||||
begin with a letter followed by any number of letters, digits and
|
begin with a letter followed by any number of letters, digits and
|
||||||
underscores. All letters must be lower case. (Full alpha-numeric
|
underscores. All letters must be lower case. (Full alpha-numeric
|
||||||
names are an extension. In POSIX \fBbc\fR all names are a single
|
names are an extension. In POSIX \fBbc\fR all names are a single
|
||||||
lower case letter.) The type of variable is clear by the context
|
lower case letter.) The type of variable is clear by the context
|
||||||
because all array variable names will be followed by brackets ([]).
|
because all array variable names will be followed by brackets ([]).
|
||||||
.PP
|
.PP
|
||||||
There are four special variables, \fBscale, ibase, obase,\fR and
|
There are four special variables, \fBscale, ibase, obase,\fR and
|
||||||
\fBlast\fR. \fBscale\fR defines how some operations use digits after the
|
\fBlast\fR. \fBscale\fR defines how some operations use digits after the
|
||||||
decimal point. The default value of \fBscale\fR is 0. \fBibase\fR
|
decimal point. The default value of \fBscale\fR is 0. \fBibase\fR
|
||||||
and \fBobase\fR define the conversion base for input and output
|
and \fBobase\fR define the conversion base for input and output
|
||||||
numbers. The default for both input and output is base 10.
|
numbers. The default for both input and output is base 10.
|
||||||
\fBlast\fR (an extension) is a variable that has the value of the last
|
\fBlast\fR (an extension) is a variable that has the value of the last
|
||||||
|
@ -125,7 +125,7 @@ by the variable \fBibase\fR. (There is an exception in functions.)
|
||||||
The legal values of \fBibase\fR are 2 through 36. (Bases greater than
|
The legal values of \fBibase\fR are 2 through 36. (Bases greater than
|
||||||
16 are an extension.) Assigning a value outside this range to
|
16 are an extension.) Assigning a value outside this range to
|
||||||
\fBibase\fR will result in a value of 2 or 36. Input numbers may
|
\fBibase\fR will result in a value of 2 or 36. Input numbers may
|
||||||
contain the characters 0-9 and A-Z. (Note: They must be capitals.
|
contain the characters 0\(en9 and A\(enZ. (Note: They must be capitals.
|
||||||
Lower case letters are variable names.) Single digit numbers always
|
Lower case letters are variable names.) Single digit numbers always
|
||||||
have the value of the digit regardless of the value of
|
have the value of the digit regardless of the value of
|
||||||
\fBibase\fR. (i.e. A = 10.) For multi-digit numbers, \fBbc\fR changes
|
\fBibase\fR. (i.e. A = 10.) For multi-digit numbers, \fBbc\fR changes
|
||||||
|
@ -149,7 +149,8 @@ A simple variable is just a
|
||||||
.RE
|
.RE
|
||||||
and an array variable is specified as
|
and an array variable is specified as
|
||||||
.RS
|
.RS
|
||||||
\fIname\fR[\fIexpr\fR]
|
.\"\fIname\fR[\fIexpr\fR]
|
||||||
|
.IR name [ expr ]
|
||||||
.RE
|
.RE
|
||||||
Unless specifically
|
Unless specifically
|
||||||
mentioned the scale of the result is the maximum scale of the
|
mentioned the scale of the result is the maximum scale of the
|
||||||
|
@ -187,13 +188,13 @@ to zero and both expressions are integers this expression is the
|
||||||
integer remainder function.
|
integer remainder function.
|
||||||
.IP "expr ^ expr"
|
.IP "expr ^ expr"
|
||||||
The result of the expression is the value of the first raised to the
|
The result of the expression is the value of the first raised to the
|
||||||
second. The second expression must be an integer. (If the second
|
second. The second expression must be an integer. (If the second
|
||||||
expression is not an integer, a warning is generated and the
|
expression is not an integer, a warning is generated and the
|
||||||
expression is truncated to get an integer value.) The scale of the
|
expression is truncated to get an integer value.) The scale of the
|
||||||
result is \fBscale\fR if the exponent is negative. If the exponent
|
result is \fBscale\fR if the exponent is negative. If the exponent
|
||||||
is positive the scale of the result is the minimum of the scale of the
|
is positive the scale of the result is the minimum of the scale of the
|
||||||
first expression times the value of the exponent and the maximum of
|
first expression times the value of the exponent and the maximum of
|
||||||
\fBscale\fR and the scale of the first expression. (e.g. scale(a^b)
|
\fBscale\fR and the scale of the first expression. (e.g.\& scale(a^b)
|
||||||
= min(scale(a)*b, max( \fBscale,\fR scale(a))).) It should be noted
|
= min(scale(a)*b, max( \fBscale,\fR scale(a))).) It should be noted
|
||||||
that expr^0 will always return the value of 1.
|
that expr^0 will always return the value of 1.
|
||||||
.IP "( expr )"
|
.IP "( expr )"
|
||||||
|
@ -226,7 +227,7 @@ The result is 1 if expr1 is equal to expr2.
|
||||||
The result is 1 if expr1 is not equal to expr2.
|
The result is 1 if expr1 is not equal to expr2.
|
||||||
.PP
|
.PP
|
||||||
Boolean operations are also legal. (POSIX \fBbc\fR does NOT have
|
Boolean operations are also legal. (POSIX \fBbc\fR does NOT have
|
||||||
boolean operations). The result of all boolean operations are 0 and 1
|
boolean operations). The result of all boolean operations are 0 and 1
|
||||||
(for false and true) as in relational expressions. The boolean
|
(for false and true) as in relational expressions. The boolean
|
||||||
operators are:
|
operators are:
|
||||||
.IP "!expr"
|
.IP "!expr"
|
||||||
|
@ -253,7 +254,7 @@ unary - operator, nonassociative
|
||||||
.fi
|
.fi
|
||||||
.PP
|
.PP
|
||||||
This precedence was chosen so that POSIX compliant \fBbc\fR programs
|
This precedence was chosen so that POSIX compliant \fBbc\fR programs
|
||||||
will run correctly. This will cause the use of the relational and
|
will run correctly. This will cause the use of the relational and
|
||||||
logical operators to have some unusual behavior when used with
|
logical operators to have some unusual behavior when used with
|
||||||
assignment expressions. Consider the expression:
|
assignment expressions. Consider the expression:
|
||||||
.RS
|
.RS
|
||||||
|
@ -268,7 +269,7 @@ with the assignment operators.
|
||||||
.PP
|
.PP
|
||||||
There are a few more special expressions that are provided in \fBbc\fR.
|
There are a few more special expressions that are provided in \fBbc\fR.
|
||||||
These have to do with user defined functions and standard
|
These have to do with user defined functions and standard
|
||||||
functions. They all appear as "\fIname\fB(\fIparameters\fB)\fR".
|
functions. They all appear as "\,\fIname\/\fB(\,\fIparameters\/\fB)\fR".
|
||||||
See the section on functions for user defined functions. The standard
|
See the section on functions for user defined functions. The standard
|
||||||
functions are:
|
functions are:
|
||||||
.IP "length ( expression )"
|
.IP "length ( expression )"
|
||||||
|
@ -281,7 +282,7 @@ cause problems with the mixing of data and program in the standard input.
|
||||||
The best use for this function is in a previously written program that
|
The best use for this function is in a previously written program that
|
||||||
needs input from the user, but never allows program code to be input
|
needs input from the user, but never allows program code to be input
|
||||||
from the user. The value of the read function is the number read from
|
from the user. The value of the read function is the number read from
|
||||||
the standard input using the current value of the variable
|
the standard input using the current value of the variable
|
||||||
\fBibase\fR for the conversion base.
|
\fBibase\fR for the conversion base.
|
||||||
.IP "scale ( expression )"
|
.IP "scale ( expression )"
|
||||||
The value of the scale function is the number of digits after the decimal
|
The value of the scale function is the number of digits after the decimal
|
||||||
|
@ -294,7 +295,7 @@ Statements (as in most algebraic languages) provide the sequencing of
|
||||||
expression evaluation. In \fBbc\fR statements are executed "as soon
|
expression evaluation. In \fBbc\fR statements are executed "as soon
|
||||||
as possible." Execution happens when a newline in encountered and
|
as possible." Execution happens when a newline in encountered and
|
||||||
there is one or more complete statements. Due to this immediate
|
there is one or more complete statements. Due to this immediate
|
||||||
execution, newlines are very important in \fBbc\fR. In fact, both a
|
execution, newlines are very important in \fBbc\fR. In fact, both a
|
||||||
semicolon and a newline are used as statement separators. An
|
semicolon and a newline are used as statement separators. An
|
||||||
improperly placed newline will cause a syntax error. Because newlines
|
improperly placed newline will cause a syntax error. Because newlines
|
||||||
are statement separators, it is possible to hide a newline by using
|
are statement separators, it is possible to hide a newline by using
|
||||||
|
@ -312,7 +313,7 @@ expression is evaluated and printed to the output. After the number
|
||||||
is printed, a newline is printed. For example, "a=1" is an assignment
|
is printed, a newline is printed. For example, "a=1" is an assignment
|
||||||
statement and "(a=1)" is an expression that has an embedded
|
statement and "(a=1)" is an expression that has an embedded
|
||||||
assignment. All numbers that are printed are printed in the base
|
assignment. All numbers that are printed are printed in the base
|
||||||
specified by the variable \fBobase\fR. The legal values for \fB
|
specified by the variable \fBobase\fR. The legal values for \fB
|
||||||
obase\fR are 2 through BC_BASE_MAX. (See the section LIMITS.) For
|
obase\fR are 2 through BC_BASE_MAX. (See the section LIMITS.) For
|
||||||
bases 2 through 16, the usual method of writing numbers is used. For
|
bases 2 through 16, the usual method of writing numbers is used. For
|
||||||
bases greater than 16, \fBbc\fR uses a multi-character digit method
|
bases greater than 16, \fBbc\fR uses a multi-character digit method
|
||||||
|
@ -325,13 +326,13 @@ These long numbers will be split across lines using the "\e" as the
|
||||||
last character on a line. The maximum number of characters printed
|
last character on a line. The maximum number of characters printed
|
||||||
per line is 70. Due to the interactive nature of \fBbc\fR, printing
|
per line is 70. Due to the interactive nature of \fBbc\fR, printing
|
||||||
a number causes the side effect of assigning the printed value to the
|
a number causes the side effect of assigning the printed value to the
|
||||||
special variable \fBlast\fR. This allows the user to recover the
|
special variable \fBlast\fR. This allows the user to recover the
|
||||||
last value printed without having to retype the expression that
|
last value printed without having to retype the expression that
|
||||||
printed the number. Assigning to \fBlast\fR is legal and will
|
printed the number. Assigning to \fBlast\fR is legal and will
|
||||||
overwrite the last printed value with the assigned value. The newly
|
overwrite the last printed value with the assigned value. The newly
|
||||||
assigned value will remain until the next number is printed or another
|
assigned value will remain until the next number is printed or another
|
||||||
value is assigned to \fBlast\fR. (Some installations may allow the
|
value is assigned to \fBlast\fR. (Some installations may allow the
|
||||||
use of a single period (.) which is not part of a number as a short
|
use of a single period (.\&) which is not part of a number as a short
|
||||||
hand notation for for \fBlast\fR.)
|
hand notation for for \fBlast\fR.)
|
||||||
.IP "string"
|
.IP "string"
|
||||||
The string is printed to the output. Strings start with a double quote
|
The string is printed to the output. Strings start with a double quote
|
||||||
|
@ -343,13 +344,13 @@ The print statement (an extension) provides another method of output.
|
||||||
The "list" is a list of strings and expressions separated by commas.
|
The "list" is a list of strings and expressions separated by commas.
|
||||||
Each string or expression is printed in the order of the list. No
|
Each string or expression is printed in the order of the list. No
|
||||||
terminating newline is printed. Expressions are evaluated and their
|
terminating newline is printed. Expressions are evaluated and their
|
||||||
value is printed and assigned to the variable \fBlast\fR. Strings
|
value is printed and assigned to the variable \fBlast\fR. Strings
|
||||||
in the print statement are printed to the output and may contain
|
in the print statement are printed to the output and may contain
|
||||||
special characters. Special characters start with the backslash
|
special characters. Special characters start with the backslash
|
||||||
character (\e). The special characters recognized by \fBbc\fR are
|
character (\e). The special characters recognized by \fBbc\fR are
|
||||||
"a" (alert or bell), "b" (backspace), "f" (form feed), "n" (newline),
|
"a" (alert or bell), "b" (backspace), "f" (form feed), "n" (newline),
|
||||||
"r" (carriage return), "q" (double quote), "t" (tab), and "\e" (backslash).
|
"r" (carriage return), "q" (double quote), "t" (tab), and "\e" (backslash).
|
||||||
Any other character following the backslash will be ignored.
|
Any other character following the backslash will be ignored.
|
||||||
.IP "{ statement_list }"
|
.IP "{ statement_list }"
|
||||||
This is the compound statement. It allows multiple statements to be
|
This is the compound statement. It allows multiple statements to be
|
||||||
grouped together for execution.
|
grouped together for execution.
|
||||||
|
@ -365,7 +366,7 @@ is non-zero. It evaluates the expression before each execution of
|
||||||
the statement. Termination of the loop is caused by a zero
|
the statement. Termination of the loop is caused by a zero
|
||||||
expression value or the execution of a break statement.
|
expression value or the execution of a break statement.
|
||||||
.IP "\fBfor\fR ( [expression1] ; [expression2] ; [expression3] ) statement"
|
.IP "\fBfor\fR ( [expression1] ; [expression2] ; [expression3] ) statement"
|
||||||
The for statement controls repeated execution of the statement.
|
The for statement controls repeated execution of the statement.
|
||||||
Expression1 is evaluated before the loop. Expression2 is evaluated
|
Expression1 is evaluated before the loop. Expression2 is evaluated
|
||||||
before each execution of the statement. If it is non-zero, the statement
|
before each execution of the statement. If it is non-zero, the statement
|
||||||
is evaluated. If it is zero, the loop is terminated. After each
|
is evaluated. If it is zero, the loop is terminated. After each
|
||||||
|
@ -374,7 +375,7 @@ of expression2. If expression1 or expression3 are missing, nothing is
|
||||||
evaluated at the point they would be evaluated.
|
evaluated at the point they would be evaluated.
|
||||||
If expression2 is missing, it is the same as substituting
|
If expression2 is missing, it is the same as substituting
|
||||||
the value 1 for expression2. (The optional expressions are an
|
the value 1 for expression2. (The optional expressions are an
|
||||||
extension. POSIX \fBbc\fR requires all three expressions.)
|
extension. POSIX \fBbc\fR requires all three expressions.)
|
||||||
The following is equivalent code for the for statement:
|
The following is equivalent code for the for statement:
|
||||||
.nf
|
.nf
|
||||||
.RS
|
.RS
|
||||||
|
@ -389,7 +390,7 @@ while (expression2) {
|
||||||
This statement causes a forced exit of the most recent enclosing while
|
This statement causes a forced exit of the most recent enclosing while
|
||||||
statement or for statement.
|
statement or for statement.
|
||||||
.IP "\fBcontinue\fR"
|
.IP "\fBcontinue\fR"
|
||||||
The continue statement (an extension) causes the most recent enclosing
|
The continue statement (an extension) causes the most recent enclosing
|
||||||
for statement to start the next iteration.
|
for statement to start the next iteration.
|
||||||
.IP "\fBhalt\fR"
|
.IP "\fBhalt\fR"
|
||||||
The halt statement (an extension) is an executed statement that causes
|
The halt statement (an extension) is an executed statement that causes
|
||||||
|
@ -399,7 +400,7 @@ not executed.
|
||||||
.IP "\fBreturn\fR"
|
.IP "\fBreturn\fR"
|
||||||
Return the value 0 from a function. (See the section on functions.)
|
Return the value 0 from a function. (See the section on functions.)
|
||||||
.IP "\fBreturn\fR ( expression )"
|
.IP "\fBreturn\fR ( expression )"
|
||||||
Return the value of the expression from a function. (See the section on
|
Return the value of the expression from a function. (See the section on
|
||||||
functions.) As an extension, the parenthesis are not required.
|
functions.) As an extension, the parenthesis are not required.
|
||||||
.SS PSEUDO STATEMENTS
|
.SS PSEUDO STATEMENTS
|
||||||
These statements are not statements in the traditional sense. They are
|
These statements are not statements in the traditional sense. They are
|
||||||
|
@ -415,7 +416,7 @@ example, "if (0 == 1) quit" will cause \fBbc\fR to terminate.
|
||||||
Print a longer warranty notice. This is an extension.
|
Print a longer warranty notice. This is an extension.
|
||||||
.SS FUNCTIONS
|
.SS FUNCTIONS
|
||||||
Functions provide a method of defining a computation that can be executed
|
Functions provide a method of defining a computation that can be executed
|
||||||
later. Functions in
|
later. Functions in
|
||||||
.B bc
|
.B bc
|
||||||
always compute a value and return it to the caller. Function definitions
|
always compute a value and return it to the caller. Function definitions
|
||||||
are "dynamic" in the sense that a function is undefined until a definition
|
are "dynamic" in the sense that a function is undefined until a definition
|
||||||
|
@ -429,13 +430,13 @@ then replaces the older definition. A function is defined as follows:
|
||||||
.RE
|
.RE
|
||||||
.fi
|
.fi
|
||||||
A function call is just an expression of the form
|
A function call is just an expression of the form
|
||||||
"\fIname\fB(\fIparameters\fB)\fR".
|
"\,\fIname\/\fB(\,\fIparameters\/\fB)\fR".
|
||||||
.PP
|
.PP
|
||||||
Parameters are numbers or arrays (an extension). In the function definition,
|
Parameters are numbers or arrays (an extension). In the function definition,
|
||||||
zero or more parameters are defined by listing their names separated by
|
zero or more parameters are defined by listing their names separated by
|
||||||
commas. All parameters are call by value parameters.
|
commas. All parameters are call by value parameters.
|
||||||
Arrays are specified in the parameter definition by
|
Arrays are specified in the parameter definition by
|
||||||
the notation "\fIname\fB[]\fR". In the function call, actual parameters
|
the notation "\,\fIname\/\fB[]\fR". In the function call, actual parameters
|
||||||
are full expressions for number parameters. The same notation is used
|
are full expressions for number parameters. The same notation is used
|
||||||
for passing arrays as for defining array parameters. The named array is
|
for passing arrays as for defining array parameters. The named array is
|
||||||
passed by value to the function. Since function definitions are dynamic,
|
passed by value to the function. Since function definitions are dynamic,
|
||||||
|
@ -464,7 +465,7 @@ The function body is a list of \fBbc\fR statements. Again, statements
|
||||||
are separated by semicolons or newlines. Return statements cause the
|
are separated by semicolons or newlines. Return statements cause the
|
||||||
termination of a function and the return of a value. There are two
|
termination of a function and the return of a value. There are two
|
||||||
versions of the return statement. The first form, "\fBreturn\fR", returns
|
versions of the return statement. The first form, "\fBreturn\fR", returns
|
||||||
the value 0 to the calling expression. The second form,
|
the value 0 to the calling expression. The second form,
|
||||||
"\fBreturn ( \fIexpression \fB)\fR", computes the value of the expression
|
"\fBreturn ( \fIexpression \fB)\fR", computes the value of the expression
|
||||||
and returns that value to the calling expression. There is an implied
|
and returns that value to the calling expression. There is an implied
|
||||||
"\fBreturn (0)\fR" at the end of every function. This allows a function
|
"\fBreturn (0)\fR" at the end of every function. This allows a function
|
||||||
|
@ -494,7 +495,7 @@ define d (n)
|
||||||
.fi
|
.fi
|
||||||
.PP
|
.PP
|
||||||
Functions may be defined as \fBvoid\fR. A void
|
Functions may be defined as \fBvoid\fR. A void
|
||||||
funtion returns no value and thus may not be used in any place that needs
|
function 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
|
a value. A void function does not produce any output when called by itself
|
||||||
on an input line. The key word \fBvoid\fR is placed between the key word
|
on an input line. The key word \fBvoid\fR is placed between the key word
|
||||||
\fBdefine\fR and the function name. For example, consider the following
|
\fBdefine\fR and the function name. For example, consider the following
|
||||||
|
@ -520,27 +521,27 @@ no zero is printed because the function is a void function.
|
||||||
.PP
|
.PP
|
||||||
Also, call by variable for arrays was added. To declare
|
Also, call by variable for arrays was added. To declare
|
||||||
a call by variable array, the declaration of the array parameter in the
|
a call by variable array, the declaration of the array parameter in the
|
||||||
function definition looks like "\fI*name\fB[]\fR". The call to the
|
function definition looks like "\,\fI*name\/\fB[]\fR". The call to the
|
||||||
function remains the same as call by value arrays.
|
function remains the same as call by value arrays.
|
||||||
.SS MATH LIBRARY
|
.SS MATH LIBRARY
|
||||||
If \fBbc\fR is invoked with the \fB-l\fR option, a math library is preloaded
|
If \fBbc\fR is invoked with the \fB-l\fR option, a math library is preloaded
|
||||||
and the default scale is set to 20. The math functions will calculate their
|
and the default scale is set to 20. The math functions will calculate their
|
||||||
results to the scale set at the time of their call.
|
results to the scale set at the time of their call.
|
||||||
The math library defines the following functions:
|
The math library defines the following functions:
|
||||||
.IP "s (\fIx\fR)"
|
.IP "s (\,\fIx\/\fR)"
|
||||||
The sine of x, x is in radians.
|
The sine of x, x is in radians.
|
||||||
.IP "c (\fIx\fR)"
|
.IP "c (\,\fIx\/\fR)"
|
||||||
The cosine of x, x is in radians.
|
The cosine of x, x is in radians.
|
||||||
.IP "a (\fIx\fR)"
|
.IP "a (\,\fIx\/\fR)"
|
||||||
The arctangent of x, arctangent returns radians.
|
The arctangent of x, arctangent returns radians.
|
||||||
.IP "l (\fIx\fR)"
|
.IP "l (\,\fIx\/\fR)"
|
||||||
The natural logarithm of x.
|
The natural logarithm of x.
|
||||||
.IP "e (\fIx\fR)"
|
.IP "e (\,\fIx\/\fR)"
|
||||||
The exponential function of raising e to the value x.
|
The exponential function of raising e to the value x.
|
||||||
.IP "j (\fIn,x\fR)"
|
.IP "j (\,\fIn,x\/\fR)"
|
||||||
The Bessel function of integer order n of x.
|
The Bessel function of integer order n of x.
|
||||||
.SS EXAMPLES
|
.SS EXAMPLES
|
||||||
In /bin/sh, the following will assign the value of "pi" to the shell
|
In /bin/sh, the following will assign the value of "pi" to the shell
|
||||||
variable \fBpi\fR.
|
variable \fBpi\fR.
|
||||||
.RS
|
.RS
|
||||||
\f(CW
|
\f(CW
|
||||||
|
@ -567,7 +568,7 @@ define e(x) {
|
||||||
if (x<0) {
|
if (x<0) {
|
||||||
m = 1
|
m = 1
|
||||||
x = \-x
|
x = \-x
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Precondition x. */
|
/* Precondition x. */
|
||||||
z = scale;
|
z = scale;
|
||||||
|
@ -599,7 +600,7 @@ define e(x) {
|
||||||
.PP
|
.PP
|
||||||
The following is code that uses the extended features of \fBbc\fR to
|
The following is code that uses the extended features of \fBbc\fR to
|
||||||
implement a simple program for calculating checkbook balances. This
|
implement a simple program for calculating checkbook balances. This
|
||||||
program is best kept in a file so that it can be used many times
|
program is best kept in a file so that it can be used many times
|
||||||
without having to retype it at every use.
|
without having to retype it at every use.
|
||||||
.nf
|
.nf
|
||||||
.RS
|
.RS
|
||||||
|
@ -646,12 +647,12 @@ retained. For \fBreadline\fR, a value of \-1 means that an unlimited
|
||||||
number of history lines are retained. Setting the value of
|
number of history lines are retained. Setting the value of
|
||||||
\fBhistory\fR to a positive number restricts the number of history
|
\fBhistory\fR to a positive number restricts the number of history
|
||||||
lines to the number given. The value of 0 disables the history
|
lines to the number given. The value of 0 disables the history
|
||||||
feature. The default value is 100. For more information, read the
|
feature. The default value is 100. For more information, read the
|
||||||
user manuals for the GNU \fBreadline\fR, \fBhistory\fR and BSD \fBlibedit\fR
|
user manuals for the GNU \fBreadline\fR, \fBhistory\fR and BSD \fBlibedit\fR
|
||||||
libraries. One can not enable both \fBreadline\fR and \fBlibedit\fR
|
libraries. One can not enable both \fBreadline\fR and \fBlibedit\fR
|
||||||
at the same time.
|
at the same time.
|
||||||
.SS DIFFERENCES
|
.SS DIFFERENCES
|
||||||
This version of
|
This version of
|
||||||
.B bc
|
.B bc
|
||||||
was implemented from the POSIX P1003.2/D11 draft and contains
|
was implemented from the POSIX P1003.2/D11 draft and contains
|
||||||
several differences and extensions relative to the draft and
|
several differences and extensions relative to the draft and
|
||||||
|
@ -666,7 +667,7 @@ debugging the parser and preparing the math library.
|
||||||
.PP
|
.PP
|
||||||
A major source of differences is
|
A major source of differences is
|
||||||
extensions, where a feature is extended to add more functionality and
|
extensions, where a feature is extended to add more functionality and
|
||||||
additions, where new features are added.
|
additions, where new features are added.
|
||||||
The following is the list of differences and extensions.
|
The following is the list of differences and extensions.
|
||||||
.IP "LANG environment"
|
.IP "LANG environment"
|
||||||
This version does not conform to the POSIX standard in the processing
|
This version does not conform to the POSIX standard in the processing
|
||||||
|
@ -683,7 +684,7 @@ Strings are not allowed to contain NUL characters. POSIX says all characters
|
||||||
must be included in strings.
|
must be included in strings.
|
||||||
.IP "last"
|
.IP "last"
|
||||||
POSIX \fBbc\fR does not have a \fBlast\fR variable. Some implementations
|
POSIX \fBbc\fR does not have a \fBlast\fR variable. Some implementations
|
||||||
of \fBbc\fR use the period (.) in a similar way.
|
of \fBbc\fR use the period (.\&) in a similar way.
|
||||||
.IP "comparisons"
|
.IP "comparisons"
|
||||||
POSIX \fBbc\fR allows comparisons only in the if statement, the while
|
POSIX \fBbc\fR allows comparisons only in the if statement, the while
|
||||||
statement, and the second expression of the for statement. Also, only
|
statement, and the second expression of the for statement. Also, only
|
||||||
|
@ -697,7 +698,7 @@ POSIX \fBbc\fR does not have the logical operators.
|
||||||
.IP "read function"
|
.IP "read function"
|
||||||
POSIX \fBbc\fR does not have a read function.
|
POSIX \fBbc\fR does not have a read function.
|
||||||
.IP "print statement"
|
.IP "print statement"
|
||||||
POSIX \fBbc\fR does not have a print statement .
|
POSIX \fBbc\fR does not have a print statement.
|
||||||
.IP "continue statement"
|
.IP "continue statement"
|
||||||
POSIX \fBbc\fR does not have a continue statement.
|
POSIX \fBbc\fR does not have a continue statement.
|
||||||
.IP "return statement"
|
.IP "return statement"
|
||||||
|
@ -709,7 +710,7 @@ not provide a method to specify an array as an actual parameter. (This
|
||||||
is most likely an oversight in the grammar.) Traditional implementations
|
is most likely an oversight in the grammar.) Traditional implementations
|
||||||
of \fBbc\fR have only call by value array parameters.
|
of \fBbc\fR have only call by value array parameters.
|
||||||
.IP "function format"
|
.IP "function format"
|
||||||
POSIX \fBbc\fR requires the opening brace on the same line as the
|
POSIX \fBbc\fR requires the opening brace on the same line as the
|
||||||
\fBdefine\fR key word and the \fBauto\fR statement on the next line.
|
\fBdefine\fR key word and the \fBauto\fR statement on the next line.
|
||||||
.IP "=+, =\-, =*, =/, =%, =^"
|
.IP "=+, =\-, =*, =/, =%, =^"
|
||||||
POSIX \fBbc\fR does not require these "old style" assignment operators to
|
POSIX \fBbc\fR does not require these "old style" assignment operators to
|
||||||
|
@ -732,7 +733,7 @@ function will not be callable and becomes undefined.
|
||||||
Syntax errors in the interactive execution code will invalidate the
|
Syntax errors in the interactive execution code will invalidate the
|
||||||
current execution block. The execution block is terminated by an
|
current execution block. The execution block is terminated by an
|
||||||
end of line that appears after a complete sequence of statements.
|
end of line that appears after a complete sequence of statements.
|
||||||
For example,
|
For example,
|
||||||
.nf
|
.nf
|
||||||
.RS
|
.RS
|
||||||
a = 1
|
a = 1
|
||||||
|
@ -762,7 +763,7 @@ are removed during the
|
||||||
clean up process. During a non-interactive
|
clean up process. During a non-interactive
|
||||||
session, the SIGINT signal will terminate the entire run of \fBbc\fR.
|
session, the SIGINT signal will terminate the entire run of \fBbc\fR.
|
||||||
.SS LIMITS
|
.SS LIMITS
|
||||||
The following are the limits currently in place for this
|
The following are the limits currently in place for this
|
||||||
.B bc
|
.B bc
|
||||||
processor. Some of them may have been changed by an installation.
|
processor. Some of them may have been changed by an installation.
|
||||||
Use the limits statement to see the actual values.
|
Use the limits statement to see the actual values.
|
||||||
|
@ -798,8 +799,8 @@ variables would typically contain function definitions for functions
|
||||||
the user wants defined every time \fBbc\fR is run.
|
the user wants defined every time \fBbc\fR is run.
|
||||||
.IP "BC_LINE_LENGTH"
|
.IP "BC_LINE_LENGTH"
|
||||||
This should be an integer specifying 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
|
output line for numbers. This includes the backslash and newline characters
|
||||||
for long numbers. As an extension, the value of zero disables the
|
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
|
multi-line feature. Any other value of this variable that is less than
|
||||||
3 sets the line length to 70.
|
3 sets the line length to 70.
|
||||||
.SH DIAGNOSTICS
|
.SH DIAGNOSTICS
|
||||||
|
@ -814,7 +815,7 @@ Email bug reports to
|
||||||
Be sure to include the word ``bc'' somewhere in the ``Subject:'' field.
|
Be sure to include the word ``bc'' somewhere in the ``Subject:'' field.
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
.nf
|
.nf
|
||||||
Philip A. Nelson
|
Philip A.\& Nelson
|
||||||
philnelson@acm.org
|
philnelson@acm.org
|
||||||
.fi
|
.fi
|
||||||
.SH ACKNOWLEDGEMENTS
|
.SH ACKNOWLEDGEMENTS
|
||||||
|
|
Loading…
Reference in New Issue