aboutsummaryrefslogtreecommitdiff
path: root/contrib/bc/manuals/bc/EP.1
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2021-04-06 08:48:09 +0000
committerStefan Eßer <se@FreeBSD.org>2021-04-06 08:48:09 +0000
commit7e5c51e523ae2a0b4f00cf5d6b9168e053d8eed1 (patch)
tree2e2c2be3547a2d6ce49e86f63a6ef950df2ce695 /contrib/bc/manuals/bc/EP.1
parent42cd37dfbd1b2feff8f7aba32d2577e08b058231 (diff)
parent7a590c074ceede12b2b6e794f8703d6fa5749918 (diff)
downloadsrc-7e5c51e523ae2a0b4f00cf5d6b9168e053d8eed1.tar.gz
src-7e5c51e523ae2a0b4f00cf5d6b9168e053d8eed1.zip
Merge commit '7a590c074ceede12b2b6e794f8703d6fa5749918'
Update to version 4.0.0 This version fixes an issue (missing pop of top-of-stack value in the "P" command of the dc program). This issue did not affect the bc program, since it does not use dc as an back-end to actually perform the calculations as was the case with the traditional bc and dc programs. The major number has been bumped due to Windows support that has been added to this version. It does not correspond to a major change that might affect FreeBSD.
Diffstat (limited to 'contrib/bc/manuals/bc/EP.1')
-rw-r--r--contrib/bc/manuals/bc/EP.1894
1 files changed, 494 insertions, 400 deletions
diff --git a/contrib/bc/manuals/bc/EP.1 b/contrib/bc/manuals/bc/EP.1
index 62ee57bfccc7..453b768082ed 100644
--- a/contrib/bc/manuals/bc/EP.1
+++ b/contrib/bc/manuals/bc/EP.1
@@ -25,19 +25,19 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
+.TH "BC" "1" "April 2021" "Gavin D. Howard" "General Commands Manual"
.SH NAME
.PP
bc - arbitrary-precision decimal arithmetic language and calculator
.SH SYNOPSIS
.PP
-\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
+\f[B]bc\f[R] [\f[B]-ghilPqRsvVw\f[R]] [\f[B]--global-stacks\f[R]]
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
-[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
-[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
-[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
-\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
-[\f[I]file\f[R]\&...]
+[\f[B]--no-prompt\f[R]] [\f[B]--no-read-prompt\f[R]] [\f[B]--quiet\f[R]]
+[\f[B]--standard\f[R]] [\f[B]--warn\f[R]] [\f[B]--version\f[R]]
+[\f[B]-e\f[R] \f[I]expr\f[R]] [\f[B]--expression\f[R]=\f[I]expr\f[R]...]
+[\f[B]-f\f[R] \f[I]file\f[R]...] [\f[B]--file\f[R]=\f[I]file\f[R]...]
+[\f[I]file\f[R]...]
.SH DESCRIPTION
.PP
bc(1) is an interactive processor for a language first standardized in
@@ -113,112 +113,145 @@ If **-s**, **-w**, or any equivalents are used, this option is ignored.
This is a **non-portable extension**.
\f[R]
.fi
-.TP
+.PP
\f[B]-h\f[R], \f[B]--help\f[R]
-Prints a usage message and quits.
-.TP
+.PP
+: Prints a usage message and quits.
+.PP
\f[B]-i\f[R], \f[B]--interactive\f[R]
-Forces interactive mode.
+.PP
+: Forces interactive mode.
(See the \f[B]INTERACTIVE MODE\f[R] section.)
-.RS
+.IP
+.nf
+\f[C]
+This is a **non-portable extension**.
+\f[R]
+.fi
.PP
-This is a \f[B]non-portable extension\f[R].
-.RE
-.TP
\f[B]-l\f[R], \f[B]--mathlib\f[R]
-Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
-and loads the included math library before running any code, including
-any expressions or files specified on the command line.
-.RS
-.PP
-To learn what is in the library, see the \f[B]LIBRARY\f[R] section.
-.RE
-.TP
+.PP
+: Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to
+\f[B]20\f[R] and loads the included math library before running any
+code, including any expressions or files specified on the command line.
+.IP
+.nf
+\f[C]
+To learn what is in the library, see the **LIBRARY** section.
+\f[R]
+.fi
+.PP
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
-This option is a no-op.
-.RS
.PP
-This is a \f[B]non-portable extension\f[R].
-.RE
-.TP
+: This option is a no-op.
+.IP
+.nf
+\f[C]
+This is a **non-portable extension**.
+\f[R]
+.fi
+.PP
+\f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
+.PP
+: Because bc(1) was built without support for prompts, this option is a
+no-op.
+.IP
+.nf
+\f[C]
+This is a **non-portable extension**.
+\f[R]
+.fi
+.PP
\f[B]-q\f[R], \f[B]--quiet\f[R]
-This option is for compatibility with the GNU
+.PP
+: This option is for compatibility with the GNU
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
Without this option, GNU bc(1) prints a copyright header.
This bc(1) only prints the copyright header if one or more of the
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
-.RS
+.IP
+.nf
+\f[C]
+This is a **non-portable extension**.
+\f[R]
+.fi
.PP
-This is a \f[B]non-portable extension\f[R].
-.RE
-.TP
\f[B]-s\f[R], \f[B]--standard\f[R]
-Process exactly the language defined by the
+.PP
+: Process exactly the language defined by the
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
and error if any extensions are used.
-.RS
+.IP
+.nf
+\f[C]
+This is a **non-portable extension**.
+\f[R]
+.fi
.PP
-This is a \f[B]non-portable extension\f[R].
-.RE
-.TP
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
-Print the version information (copyright header) and exit.
-.RS
.PP
-This is a \f[B]non-portable extension\f[R].
-.RE
-.TP
+: Print the version information (copyright header) and exit.
+.IP
+.nf
+\f[C]
+This is a **non-portable extension**.
+\f[R]
+.fi
+.PP
\f[B]-w\f[R], \f[B]--warn\f[R]
-Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
+.PP
+: Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
not errors) are printed for non-standard extensions and execution
continues normally.
-.RS
+.IP
+.nf
+\f[C]
+This is a **non-portable extension**.
+\f[R]
+.fi
.PP
-This is a \f[B]non-portable extension\f[R].
-.RE
-.TP
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
-Evaluates \f[I]expr\f[R].
+.PP
+: Evaluates \f[I]expr\f[R].
If multiple expressions are given, they are evaluated in order.
If files are given as well (see below), the expressions and files are
evaluated in the order given.
This means that if a file is given before an expression, the file is
read in and evaluated first.
-.RS
-.PP
-If this option is given on the command-line (i.e., not in
-\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
-then after processing all expressions and files, bc(1) will exit, unless
-\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
-\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
-\f[B]BC_ENV_ARGS\f[R].
-However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
-\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
-\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
-exit.
+.IP
+.nf
+\f[C]
+If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
+see the **ENVIRONMENT VARIABLES** section), then after processing all
+expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
+as an argument at least once to **-f** or **-\[rs]-file**, whether on the
+command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
+**-\[rs]-expression**, **-f**, or **-\[rs]-file** arguments are given after **-f-**
+or equivalent is given, bc(1) will give a fatal error and exit.
+
+This is a **non-portable extension**.
+\f[R]
+.fi
.PP
-This is a \f[B]non-portable extension\f[R].
-.RE
-.TP
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
-Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
+.PP
+: Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
were read through \f[B]stdin\f[R].
If expressions are also given (see above), the expressions are evaluated
in the order given.
-.RS
-.PP
-If this option is given on the command-line (i.e., not in
-\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
-then after processing all expressions and files, bc(1) will exit, unless
-\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
-\f[B]-f\f[R] or \f[B]--file\f[R].
-However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
-\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
-\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
-exit.
-.PP
-This is a \f[B]non-portable extension\f[R].
-.RE
+.IP
+.nf
+\f[C]
+If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
+see the **ENVIRONMENT VARIABLES** section), then after processing all
+expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
+as an argument at least once to **-f** or **-\[rs]-file**. However, if any other
+**-e**, **-\[rs]-expression**, **-f**, or **-\[rs]-file** arguments are given after
+**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
+
+This is a **non-portable extension**.
+\f[R]
+.fi
.PP
All long options are \f[B]non-portable extensions\f[R].
.SH STDOUT
@@ -275,7 +308,7 @@ Identifiers with more than one character (letter) are a
.PP
\f[B]ibase\f[R] is a global variable determining how to interpret
constant numbers.
-It is the \[lq]input\[rq] base, or the number base used for interpreting
+It is the \[dq]input\[dq] base, or the number base used for interpreting
input numbers.
\f[B]ibase\f[R] is initially \f[B]10\f[R].
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
@@ -287,7 +320,7 @@ The max allowable value for \f[B]ibase\f[R] can be queried in bc(1)
programs with the \f[B]maxibase()\f[R] built-in function.
.PP
\f[B]obase\f[R] is a global variable determining how to output results.
-It is the \[lq]output\[rq] base, or the number base used for outputting
+It is the \[dq]output\[dq] base, or the number base used for outputting
numbers.
\f[B]obase\f[R] is initially \f[B]10\f[R].
The max allowable value for \f[B]obase\f[R] is \f[B]BC_BASE_MAX\f[R] and
@@ -438,223 +471,281 @@ This means that \f[B]A\f[R] alone always equals decimal \f[B]10\f[R] and
The following arithmetic and logical operators can be used.
They are listed in order of decreasing precedence.
Operators in the same group have the same precedence.
-.TP
+.PP
\f[B]++\f[R] \f[B]--\f[R]
-Type: Prefix and Postfix
-.RS
.PP
+: Type: Prefix and Postfix
+.IP
+.nf
+\f[C]
Associativity: None
+
+Description: **increment**, **decrement**
+\f[R]
+.fi
.PP
-Description: \f[B]increment\f[R], \f[B]decrement\f[R]
-.RE
-.TP
\f[B]-\f[R] \f[B]!\f[R]
-Type: Prefix
-.RS
.PP
+: Type: Prefix
+.IP
+.nf
+\f[C]
Associativity: None
+
+Description: **negation**, **boolean not**
+\f[R]
+.fi
.PP
-Description: \f[B]negation\f[R], \f[B]boolean not\f[R]
-.RE
-.TP
\f[B]\[ha]\f[R]
-Type: Binary
-.RS
.PP
+: Type: Binary
+.IP
+.nf
+\f[C]
Associativity: Right
+
+Description: **power**
+\f[R]
+.fi
.PP
-Description: \f[B]power\f[R]
-.RE
-.TP
\f[B]*\f[R] \f[B]/\f[R] \f[B]%\f[R]
-Type: Binary
-.RS
.PP
+: Type: Binary
+.IP
+.nf
+\f[C]
Associativity: Left
+
+Description: **multiply**, **divide**, **modulus**
+\f[R]
+.fi
.PP
-Description: \f[B]multiply\f[R], \f[B]divide\f[R], \f[B]modulus\f[R]
-.RE
-.TP
\f[B]+\f[R] \f[B]-\f[R]
-Type: Binary
-.RS
.PP
+: Type: Binary
+.IP
+.nf
+\f[C]
Associativity: Left
+
+Description: **add**, **subtract**
+\f[R]
+.fi
.PP
-Description: \f[B]add\f[R], \f[B]subtract\f[R]
-.RE
-.TP
-\f[B]=\f[R] \f[B]+=\f[R] \f[B]-=\f[R] \f[B]*=\f[R] \f[B]/=\f[R] \f[B]%=\f[R] \f[B]\[ha]=\f[R]
-Type: Binary
-.RS
+\f[B]=\f[R] \f[B]+=\f[R] \f[B]-=\f[R] \f[B]*=\f[R] \f[B]/=\f[R]
+\f[B]%=\f[R] \f[B]\[ha]=\f[R]
.PP
+: Type: Binary
+.IP
+.nf
+\f[C]
Associativity: Right
+
+Description: **assignment**
+\f[R]
+.fi
.PP
-Description: \f[B]assignment\f[R]
-.RE
-.TP
-\f[B]==\f[R] \f[B]<=\f[R] \f[B]>=\f[R] \f[B]!=\f[R] \f[B]<\f[R] \f[B]>\f[R]
-Type: Binary
-.RS
+\f[B]==\f[R] \f[B]<=\f[R] \f[B]>=\f[R] \f[B]!=\f[R] \f[B]<\f[R]
+\f[B]>\f[R]
.PP
+: Type: Binary
+.IP
+.nf
+\f[C]
Associativity: Left
+
+Description: **relational**
+\f[R]
+.fi
.PP
-Description: \f[B]relational\f[R]
-.RE
-.TP
\f[B]&&\f[R]
-Type: Binary
-.RS
.PP
+: Type: Binary
+.IP
+.nf
+\f[C]
Associativity: Left
+
+Description: **boolean and**
+\f[R]
+.fi
.PP
-Description: \f[B]boolean and\f[R]
-.RE
-.TP
\f[B]||\f[R]
-Type: Binary
-.RS
.PP
+: Type: Binary
+.IP
+.nf
+\f[C]
Associativity: Left
-.PP
-Description: \f[B]boolean or\f[R]
-.RE
+
+Description: **boolean or**
+\f[R]
+.fi
.PP
The operators will be described in more detail below.
-.TP
+.PP
\f[B]++\f[R] \f[B]--\f[R]
-The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
+.PP
+: The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
operators behave exactly like they would in C.
They require a named expression (see the \f[I]Named Expressions\f[R]
subsection) as an operand.
-.RS
+.IP
+.nf
+\f[C]
+The prefix versions of these operators are more efficient; use them where
+possible.
+\f[R]
+.fi
.PP
-The prefix versions of these operators are more efficient; use them
-where possible.
-.RE
-.TP
\f[B]-\f[R]
-The \f[B]negation\f[R] operator returns \f[B]0\f[R] if a user attempts
+.PP
+: The \f[B]negation\f[R] operator returns \f[B]0\f[R] if a user attempts
to negate any expression with the value \f[B]0\f[R].
Otherwise, a copy of the expression with its sign flipped is returned.
-.TP
+.PP
\f[B]!\f[R]
-The \f[B]boolean not\f[R] operator returns \f[B]1\f[R] if the expression
-is \f[B]0\f[R], or \f[B]0\f[R] otherwise.
-.RS
.PP
-This is a \f[B]non-portable extension\f[R].
-.RE
-.TP
+: The \f[B]boolean not\f[R] operator returns \f[B]1\f[R] if the
+expression is \f[B]0\f[R], or \f[B]0\f[R] otherwise.
+.IP
+.nf
+\f[C]
+This is a **non-portable extension**.
+\f[R]
+.fi
+.PP
\f[B]\[ha]\f[R]
-The \f[B]power\f[R] operator (not the \f[B]exclusive or\f[R] operator,
+.PP
+: The \f[B]power\f[R] operator (not the \f[B]exclusive or\f[R] operator,
as it would be in C) takes two expressions and raises the first to the
power of the value of the second.
The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
-.RS
+.IP
+.nf
+\f[C]
+The second expression must be an integer (no *scale*), and if it is
+negative, the first value must be non-zero.
+\f[R]
+.fi
.PP
-The second expression must be an integer (no \f[I]scale\f[R]), and if it
-is negative, the first value must be non-zero.
-.RE
-.TP
\f[B]*\f[R]
-The \f[B]multiply\f[R] operator takes two expressions, multiplies them,
-and returns the product.
+.PP
+: The \f[B]multiply\f[R] operator takes two expressions, multiplies
+them, and returns the product.
If \f[B]a\f[R] is the \f[I]scale\f[R] of the first expression and
\f[B]b\f[R] is the \f[I]scale\f[R] of the second expression, the
\f[I]scale\f[R] of the result is equal to
\f[B]min(a+b,max(scale,a,b))\f[R] where \f[B]min()\f[R] and
\f[B]max()\f[R] return the obvious values.
-.TP
+.PP
\f[B]/\f[R]
-The \f[B]divide\f[R] operator takes two expressions, divides them, and
+.PP
+: The \f[B]divide\f[R] operator takes two expressions, divides them, and
returns the quotient.
The \f[I]scale\f[R] of the result shall be the value of \f[B]scale\f[R].
-.RS
-.PP
+.IP
+.nf
+\f[C]
The second expression must be non-zero.
-.RE
-.TP
+\f[R]
+.fi
+.PP
\f[B]%\f[R]
-The \f[B]modulus\f[R] operator takes two expressions, \f[B]a\f[R] and
+.PP
+: The \f[B]modulus\f[R] operator takes two expressions, \f[B]a\f[R] and
\f[B]b\f[R], and evaluates them by 1) Computing \f[B]a/b\f[R] to current
\f[B]scale\f[R] and 2) Using the result of step 1 to calculate
\f[B]a-(a/b)*b\f[R] to \f[I]scale\f[R]
\f[B]max(scale+scale(b),scale(a))\f[R].
-.RS
-.PP
+.IP
+.nf
+\f[C]
The second expression must be non-zero.
-.RE
-.TP
+\f[R]
+.fi
+.PP
\f[B]+\f[R]
-The \f[B]add\f[R] operator takes two expressions, \f[B]a\f[R] and
+.PP
+: The \f[B]add\f[R] operator takes two expressions, \f[B]a\f[R] and
\f[B]b\f[R], and returns the sum, with a \f[I]scale\f[R] equal to the
max of the \f[I]scale\f[R]s of \f[B]a\f[R] and \f[B]b\f[R].
-.TP
+.PP
\f[B]-\f[R]
-The \f[B]subtract\f[R] operator takes two expressions, \f[B]a\f[R] and
+.PP
+: The \f[B]subtract\f[R] operator takes two expressions, \f[B]a\f[R] and
\f[B]b\f[R], and returns the difference, with a \f[I]scale\f[R] equal to
the max of the \f[I]scale\f[R]s of \f[B]a\f[R] and \f[B]b\f[R].
-.TP
-\f[B]=\f[R] \f[B]+=\f[R] \f[B]-=\f[R] \f[B]*=\f[R] \f[B]/=\f[R] \f[B]%=\f[R] \f[B]\[ha]=\f[R]
-The \f[B]assignment\f[R] operators take two expressions, \f[B]a\f[R] and
-\f[B]b\f[R] where \f[B]a\f[R] is a named expression (see the \f[I]Named
-Expressions\f[R] subsection).
-.RS
-.PP
-For \f[B]=\f[R], \f[B]b\f[R] is copied and the result is assigned to
-\f[B]a\f[R].
-For all others, \f[B]a\f[R] and \f[B]b\f[R] are applied as operands to
-the corresponding arithmetic operator and the result is assigned to
-\f[B]a\f[R].
-.RE
-.TP
-\f[B]==\f[R] \f[B]<=\f[R] \f[B]>=\f[R] \f[B]!=\f[R] \f[B]<\f[R] \f[B]>\f[R]
-The \f[B]relational\f[R] operators compare two expressions, \f[B]a\f[R]
-and \f[B]b\f[R], and if the relation holds, according to C language
-semantics, the result is \f[B]1\f[R].
-Otherwise, it is \f[B]0\f[R].
-.RS
.PP
+\f[B]=\f[R] \f[B]+=\f[R] \f[B]-=\f[R] \f[B]*=\f[R] \f[B]/=\f[R]
+\f[B]%=\f[R] \f[B]\[ha]=\f[R]
+.PP
+: The \f[B]assignment\f[R] operators take two expressions, \f[B]a\f[R]
+and \f[B]b\f[R] where \f[B]a\f[R] is a named expression (see the
+\f[I]Named Expressions\f[R] subsection).
+.IP
+.nf
+\f[C]
+For **=**, **b** is copied and the result is assigned to **a**. For all
+others, **a** and **b** are applied as operands to the corresponding
+arithmetic operator and the result is assigned to **a**.
+\f[R]
+.fi
+.PP
+\f[B]==\f[R] \f[B]<=\f[R] \f[B]>=\f[R] \f[B]!=\f[R] \f[B]<\f[R]
+\f[B]>\f[R]
+.PP
+: The \f[B]relational\f[R] operators compare two expressions,
+\f[B]a\f[R] and \f[B]b\f[R], and if the relation holds, according to C
+language semantics, the result is \f[B]1\f[R].
+Otherwise, it is \f[B]0\f[R].
+.IP
+.nf
+\f[C]
Note that unlike in C, these operators have a lower precedence than the
-\f[B]assignment\f[R] operators, which means that \f[B]a=b>c\f[R] is
-interpreted as \f[B](a=b)>c\f[R].
+**assignment** operators, which means that **a=b\[rs]>c** is interpreted as
+**(a=b)\[rs]>c**.
+
+Also, unlike the [standard][1] requires, these operators can appear anywhere
+any other expressions can be used. This allowance is a
+**non-portable extension**.
+\f[R]
+.fi
.PP
-Also, unlike the
-standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
-requires, these operators can appear anywhere any other expressions can
-be used.
-This allowance is a \f[B]non-portable extension\f[R].
-.RE
-.TP
\f[B]&&\f[R]
-The \f[B]boolean and\f[R] operator takes two expressions and returns
-\f[B]1\f[R] if both expressions are non-zero, \f[B]0\f[R] otherwise.
-.RS
.PP
-This is \f[I]not\f[R] a short-circuit operator.
+: The \f[B]boolean and\f[R] operator takes two expressions and returns
+\f[B]1\f[R] if both expressions are non-zero, \f[B]0\f[R] otherwise.
+.IP
+.nf
+\f[C]
+This is *not* a short-circuit operator.
+
+This is a **non-portable extension**.
+\f[R]
+.fi
.PP
-This is a \f[B]non-portable extension\f[R].
-.RE
-.TP
\f[B]||\f[R]
-The \f[B]boolean or\f[R] operator takes two expressions and returns
+.PP
+: The \f[B]boolean or\f[R] operator takes two expressions and returns
\f[B]1\f[R] if one of the expressions is non-zero, \f[B]0\f[R]
otherwise.
-.RS
-.PP
-This is \f[I]not\f[R] a short-circuit operator.
-.PP
-This is a \f[B]non-portable extension\f[R].
-.RE
+.IP
+.nf
+\f[C]
+This is *not* a short-circuit operator.
+
+This is a **non-portable extension**.
+\f[R]
+.fi
.SS Statements
.PP
The following items are statements:
.IP " 1." 4
\f[B]E\f[R]
.IP " 2." 4
-\f[B]{\f[R] \f[B]S\f[R] \f[B];\f[R] \&... \f[B];\f[R] \f[B]S\f[R]
-\f[B]}\f[R]
+\f[B]{\f[R] \f[B]S\f[R] \f[B];\f[R] ...
+\f[B];\f[R] \f[B]S\f[R] \f[B]}\f[R]
.IP " 3." 4
\f[B]if\f[R] \f[B](\f[R] \f[B]E\f[R] \f[B])\f[R] \f[B]S\f[R]
.IP " 4." 4
@@ -680,7 +771,8 @@ An empty statement
.IP "13." 4
A string of characters, enclosed in double quotes
.IP "14." 4
-\f[B]print\f[R] \f[B]E\f[R] \f[B],\f[R] \&... \f[B],\f[R] \f[B]E\f[R]
+\f[B]print\f[R] \f[B]E\f[R] \f[B],\f[R] ...
+\f[B],\f[R] \f[B]E\f[R]
.IP "15." 4
\f[B]I()\f[R], \f[B]I(E)\f[R], \f[B]I(E, E)\f[R], and so on, where
\f[B]I\f[R] is an identifier for a \f[B]void\f[R] function (see the
@@ -724,62 +816,22 @@ command.
An expression by itself is evaluated and printed, followed by a newline.
.SS Print Statement
.PP
-The \[lq]expressions\[rq] in a \f[B]print\f[R] statement may also be
+The \[dq]expressions\[dq] in a \f[B]print\f[R] statement may also be
strings.
If they are, there are backslash escape sequences that are interpreted
specially.
What those sequences are, and what they cause to be printed, are shown
below:
.PP
-.TS
-tab(@);
-l l.
-T{
-\f[B]\[rs]a\f[R]
-T}@T{
-\f[B]\[rs]a\f[R]
-T}
-T{
-\f[B]\[rs]b\f[R]
-T}@T{
-\f[B]\[rs]b\f[R]
-T}
-T{
-\f[B]\[rs]\[rs]\f[R]
-T}@T{
-\f[B]\[rs]\f[R]
-T}
-T{
-\f[B]\[rs]e\f[R]
-T}@T{
-\f[B]\[rs]\f[R]
-T}
-T{
-\f[B]\[rs]f\f[R]
-T}@T{
-\f[B]\[rs]f\f[R]
-T}
-T{
-\f[B]\[rs]n\f[R]
-T}@T{
-\f[B]\[rs]n\f[R]
-T}
-T{
-\f[B]\[rs]q\f[R]
-T}@T{
-\f[B]\[dq]\f[R]
-T}
-T{
-\f[B]\[rs]r\f[R]
-T}@T{
-\f[B]\[rs]r\f[R]
-T}
-T{
-\f[B]\[rs]t\f[R]
-T}@T{
-\f[B]\[rs]t\f[R]
-T}
-.TE
+ * * * * *
+.PP
+\f[B]\[rs]a\f[R] \f[B]\[rs]a\f[R] \f[B]\[rs]b\f[R] \f[B]\[rs]b\f[R]
+\f[B]\[rs]\[rs]\f[R] \f[B]\[rs]\f[R] \f[B]\[rs]e\f[R] \f[B]\[rs]\f[R]
+\f[B]\[rs]f\f[R] \f[B]\[rs]f\f[R] \f[B]\[rs]n\f[R] \f[B]\[rs]n\f[R]
+\f[B]\[rs]q\f[R] \f[B]\[dq]\f[R] \f[B]\[rs]r\f[R] \f[B]\[rs]r\f[R]
+\f[B]\[rs]t\f[R] \f[B]\[rs]t\f[R]
+.PP
+ * * * * *
.PP
Any other character following a backslash causes the backslash and
character to be printed as-is.
@@ -875,9 +927,9 @@ Void functions can only use the first two \f[B]return\f[R] statements
listed above.
They can also omit the return statement entirely.
.PP
-The word \[lq]void\[rq] is not treated as a keyword; it is still
+The word \[dq]void\[dq] is not treated as a keyword; it is still
possible to have variables, arrays, and functions named \f[B]void\f[R].
-The word \[lq]void\[rq] is only treated specially right after the
+The word \[dq]void\[dq] is only treated specially right after the
\f[B]define\f[R] keyword.
.PP
This is a \f[B]non-portable extension\f[R].
@@ -908,55 +960,74 @@ All of the functions below are available when the \f[B]-l\f[R] or
The
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
defines the following functions for the math library:
-.TP
+.PP
\f[B]s(x)\f[R]
-Returns the sine of \f[B]x\f[R], which is assumed to be in radians.
-.RS
.PP
-This is a transcendental function (see the \f[I]Transcendental
-Functions\f[R] subsection below).
-.RE
-.TP
+: Returns the sine of \f[B]x\f[R], which is assumed to be in radians.
+.IP
+.nf
+\f[C]
+This is a transcendental function (see the *Transcendental Functions*
+subsection below).
+\f[R]
+.fi
+.PP
\f[B]c(x)\f[R]
-Returns the cosine of \f[B]x\f[R], which is assumed to be in radians.
-.RS
.PP
-This is a transcendental function (see the \f[I]Transcendental
-Functions\f[R] subsection below).
-.RE
-.TP
+: Returns the cosine of \f[B]x\f[R], which is assumed to be in radians.
+.IP
+.nf
+\f[C]
+This is a transcendental function (see the *Transcendental Functions*
+subsection below).
+\f[R]
+.fi
+.PP
\f[B]a(x)\f[R]
-Returns the arctangent of \f[B]x\f[R], in radians.
-.RS
.PP
-This is a transcendental function (see the \f[I]Transcendental
-Functions\f[R] subsection below).
-.RE
-.TP
+: Returns the arctangent of \f[B]x\f[R], in radians.
+.IP
+.nf
+\f[C]
+This is a transcendental function (see the *Transcendental Functions*
+subsection below).
+\f[R]
+.fi
+.PP
\f[B]l(x)\f[R]
-Returns the natural logarithm of \f[B]x\f[R].
-.RS
.PP
-This is a transcendental function (see the \f[I]Transcendental
-Functions\f[R] subsection below).
-.RE
-.TP
+: Returns the natural logarithm of \f[B]x\f[R].
+.IP
+.nf
+\f[C]
+This is a transcendental function (see the *Transcendental Functions*
+subsection below).
+\f[R]
+.fi
+.PP
\f[B]e(x)\f[R]
-Returns the mathematical constant \f[B]e\f[R] raised to the power of
+.PP
+: Returns the mathematical constant \f[B]e\f[R] raised to the power of
\f[B]x\f[R].
-.RS
+.IP
+.nf
+\f[C]
+This is a transcendental function (see the *Transcendental Functions*
+subsection below).
+\f[R]
+.fi
.PP
-This is a transcendental function (see the \f[I]Transcendental
-Functions\f[R] subsection below).
-.RE
-.TP
\f[B]j(x, n)\f[R]
-Returns the bessel integer order \f[B]n\f[R] (truncated) of \f[B]x\f[R].
-.RS
.PP
-This is a transcendental function (see the \f[I]Transcendental
-Functions\f[R] subsection below).
-.RE
+: Returns the bessel integer order \f[B]n\f[R] (truncated) of
+\f[B]x\f[R].
+.IP
+.nf
+\f[C]
+This is a transcendental function (see the *Transcendental Functions*
+subsection below).
+\f[R]
+.fi
.SS Transcendental Functions
.PP
All transcendental functions can return slightly inaccurate results (up
@@ -1032,59 +1103,71 @@ always at least twice as large as the integer type used to store digits.
.SH LIMITS
.PP
The following are the limits on bc(1):
-.TP
+.PP
\f[B]BC_LONG_BIT\f[R]
-The number of bits in the \f[B]long\f[R] type in the environment where
+.PP
+: The number of bits in the \f[B]long\f[R] type in the environment where
bc(1) was built.
This determines how many decimal digits can be stored in a single large
integer (see the \f[B]PERFORMANCE\f[R] section).
-.TP
+.PP
\f[B]BC_BASE_DIGS\f[R]
-The number of decimal digits per large integer (see the
+.PP
+: The number of decimal digits per large integer (see the
\f[B]PERFORMANCE\f[R] section).
Depends on \f[B]BC_LONG_BIT\f[R].
-.TP
+.PP
\f[B]BC_BASE_POW\f[R]
-The max decimal number that each large integer can store (see
+.PP
+: The max decimal number that each large integer can store (see
\f[B]BC_BASE_DIGS\f[R]) plus \f[B]1\f[R].
Depends on \f[B]BC_BASE_DIGS\f[R].
-.TP
+.PP
\f[B]BC_OVERFLOW_MAX\f[R]
-The max number that the overflow type (see the \f[B]PERFORMANCE\f[R]
+.PP
+: The max number that the overflow type (see the \f[B]PERFORMANCE\f[R]
section) can hold.
Depends on \f[B]BC_LONG_BIT\f[R].
-.TP
+.PP
\f[B]BC_BASE_MAX\f[R]
-The maximum output base.
+.PP
+: The maximum output base.
Set at \f[B]BC_BASE_POW\f[R].
-.TP
+.PP
\f[B]BC_DIM_MAX\f[R]
-The maximum size of arrays.
+.PP
+: The maximum size of arrays.
Set at \f[B]SIZE_MAX-1\f[R].
-.TP
+.PP
\f[B]BC_SCALE_MAX\f[R]
-The maximum \f[B]scale\f[R].
+.PP
+: The maximum \f[B]scale\f[R].
Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
-.TP
+.PP
\f[B]BC_STRING_MAX\f[R]
-The maximum length of strings.
+.PP
+: The maximum length of strings.
Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
-.TP
+.PP
\f[B]BC_NAME_MAX\f[R]
-The maximum length of identifiers.
+.PP
+: The maximum length of identifiers.
Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
-.TP
+.PP
\f[B]BC_NUM_MAX\f[R]
-The maximum length of a number (in decimal digits), which includes
+.PP
+: The maximum length of a number (in decimal digits), which includes
digits after the decimal point.
Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
-.TP
+.PP
Exponent
-The maximum allowable exponent (positive or negative).
+.PP
+: The maximum allowable exponent (positive or negative).
Set at \f[B]BC_OVERFLOW_MAX\f[R].
-.TP
+.PP
Number of vars
-The maximum number of vars/arrays.
+.PP
+: The maximum number of vars/arrays.
Set at \f[B]SIZE_MAX-1\f[R].
.PP
The actual values can be queried with the \f[B]limits\f[R] statement.
@@ -1096,42 +1179,44 @@ In fact, memory should be exhausted before these limits should be hit.
.SH ENVIRONMENT VARIABLES
.PP
bc(1) recognizes the following environment variables:
-.TP
+.PP
\f[B]POSIXLY_CORRECT\f[R]
-If this variable exists (no matter the contents), bc(1) behaves as if
+.PP
+: If this variable exists (no matter the contents), bc(1) behaves as if
the \f[B]-s\f[R] option was given.
-.TP
+.PP
\f[B]BC_ENV_ARGS\f[R]
-This is another way to give command-line arguments to bc(1).
+.PP
+: This is another way to give command-line arguments to bc(1).
They should be in the same format as all other command-line arguments.
These are always processed first, so any files given in
\f[B]BC_ENV_ARGS\f[R] will be processed before arguments and files given
on the command-line.
-This gives the user the ability to set up \[lq]standard\[rq] options and
+This gives the user the ability to set up \[dq]standard\[dq] options and
files to be used at every invocation.
The most useful thing for such files to contain would be useful
functions that the user might want every time bc(1) runs.
-.RS
-.PP
-The code that parses \f[B]BC_ENV_ARGS\f[R] will correctly handle quoted
-arguments, but it does not understand escape sequences.
-For example, the string \f[B]\[lq]/home/gavin/some bc file.bc\[rq]\f[R]
-will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
-\[dq]bc\[dq] file.bc\[rq]\f[R] will include the backslashes.
-.PP
-The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
-\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
-quotes in the name, you can use double quotes as the outside quotes, as
-in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
-file with double quotes.
-However, handling a file with both kinds of quotes in
-\f[B]BC_ENV_ARGS\f[R] is not supported due to the complexity of the
-parsing, though such files are still supported on the command-line where
-the parsing is done by the shell.
-.RE
-.TP
+.IP
+.nf
+\f[C]
+The code that parses **BC_ENV_ARGS** will correctly handle quoted arguments,
+but it does not understand escape sequences. For example, the string
+**\[dq]/home/gavin/some bc file.bc\[dq]** will be correctly parsed, but the string
+**\[dq]/home/gavin/some \[rs]\[dq]bc\[rs]\[dq] file.bc\[dq]** will include the backslashes.
+
+The quote parsing will handle either kind of quotes, **\[aq]** or **\[dq]**. Thus,
+if you have a file with any number of single quotes in the name, you can use
+double quotes as the outside quotes, as in **\[dq]some \[aq]bc\[aq] file.bc\[dq]**, and vice
+versa if you have a file with double quotes. However, handling a file with
+both kinds of quotes in **BC_ENV_ARGS** is not supported due to the
+complexity of the parsing, though such files are still supported on the
+command-line where the parsing is done by the shell.
+\f[R]
+.fi
+.PP
\f[B]BC_LINE_LENGTH\f[R]
-If this environment variable exists and contains an integer that is
+.PP
+: If this environment variable exists and contains an integer that is
greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), bc(1) will output lines to that length,
including the backslash (\f[B]\[rs]\f[R]).
@@ -1139,65 +1224,74 @@ The default line length is \f[B]70\f[R].
.SH EXIT STATUS
.PP
bc(1) returns the following exit statuses:
-.TP
+.PP
\f[B]0\f[R]
-No error.
-.TP
+.PP
+: No error.
+.PP
\f[B]1\f[R]
-A math error occurred.
+.PP
+: A math error occurred.
This follows standard practice of using \f[B]1\f[R] for expected errors,
since math errors will happen in the process of normal execution.
-.RS
-.PP
-Math errors include divide by \f[B]0\f[R], taking the square root of a
-negative number, attempting to convert a negative number to a hardware
-integer, overflow when converting a number to a hardware integer, and
-attempting to use a non-integer where an integer is required.
-.PP
-Converting to a hardware integer happens for the second operand of the
-power (\f[B]\[ha]\f[R]) operator and the corresponding assignment
-operator.
-.RE
-.TP
+.IP
+.nf
+\f[C]
+Math errors include divide by **0**, taking the square root of a negative
+number, attempting to convert a negative number to a hardware integer,
+overflow when converting a number to a hardware integer, and attempting to
+use a non-integer where an integer is required.
+
+Converting to a hardware integer happens for the second operand of the power
+(**\[rs]\[ha]**) operator and the corresponding assignment operator.
+\f[R]
+.fi
+.PP
\f[B]2\f[R]
-A parse error occurred.
-.RS
-.PP
-Parse errors include unexpected \f[B]EOF\f[R], using an invalid
-character, failing to find the end of a string or comment, using a token
-where it is invalid, giving an invalid expression, giving an invalid
-print statement, giving an invalid function definition, attempting to
-assign to an expression that is not a named expression (see the
-\f[I]Named Expressions\f[R] subsection of the \f[B]SYNTAX\f[R] section),
-giving an invalid \f[B]auto\f[R] list, having a duplicate
-\f[B]auto\f[R]/function parameter, failing to find the end of a code
-block, attempting to return a value from a \f[B]void\f[R] function,
-attempting to use a variable as a reference, and using any extensions
-when the option \f[B]-s\f[R] or any equivalents were given.
-.RE
-.TP
+.PP
+: A parse error occurred.
+.IP
+.nf
+\f[C]
+Parse errors include unexpected **EOF**, using an invalid character, failing
+to find the end of a string or comment, using a token where it is invalid,
+giving an invalid expression, giving an invalid print statement, giving an
+invalid function definition, attempting to assign to an expression that is
+not a named expression (see the *Named Expressions* subsection of the
+**SYNTAX** section), giving an invalid **auto** list, having a duplicate
+**auto**/function parameter, failing to find the end of a code block,
+attempting to return a value from a **void** function, attempting to use a
+variable as a reference, and using any extensions when the option **-s** or
+any equivalents were given.
+\f[R]
+.fi
+.PP
\f[B]3\f[R]
-A runtime error occurred.
-.RS
.PP
-Runtime errors include assigning an invalid number to \f[B]ibase\f[R],
-\f[B]obase\f[R], or \f[B]scale\f[R]; give a bad expression to a
-\f[B]read()\f[R] call, calling \f[B]read()\f[R] inside of a
-\f[B]read()\f[R] call, type errors, passing the wrong number of
+: A runtime error occurred.
+.IP
+.nf
+\f[C]
+Runtime errors include assigning an invalid number to **ibase**, **obase**,
+or **scale**; give a bad expression to a **read()** call, calling **read()**
+inside of a **read()** call, type errors, passing the wrong number of
arguments to functions, attempting to call an undefined function, and
-attempting to use a \f[B]void\f[R] function call as a value in an
-expression.
-.RE
-.TP
+attempting to use a **void** function call as a value in an expression.
+\f[R]
+.fi
+.PP
\f[B]4\f[R]
-A fatal error occurred.
-.RS
.PP
-Fatal errors include memory allocation errors, I/O errors, failing to
-open files, attempting to use files that do not have only ASCII
-characters (bc(1) only accepts ASCII characters), attempting to open a
-directory as a file, and giving invalid command-line options.
-.RE
+: A fatal error occurred.
+.IP
+.nf
+\f[C]
+Fatal errors include memory allocation errors, I/O errors, failing to open
+files, attempting to use files that do not have only ASCII characters (bc(1)
+only accepts ASCII characters), attempting to open a directory as a file,
+and giving invalid command-line options.
+\f[R]
+.fi
.PP
The exit status \f[B]4\f[R] is special; when a fatal error occurs, bc(1)
always exits and returns \f[B]4\f[R], no matter what mode bc(1) is in.
@@ -1227,7 +1321,7 @@ In interactive mode, bc(1) attempts to recover from errors (see the
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, bc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, bc(1) turns on \[dq]TTY mode.\[dq]
.PP
TTY mode is required for history to be enabled (see the \f[B]COMMAND
LINE HISTORY\f[R] section).
@@ -1247,7 +1341,7 @@ If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
-Note that \[lq]current input\[rq] can mean one of two things.
+Note that \[dq]current input\[dq] can mean one of two things.
If bc(1) is processing input from \f[B]stdin\f[R] in TTY mode, it will
ask for more input.
If bc(1) is processing input from a file in TTY mode, it will stop