Thu Jan 7 21:21:35 2021 UTC ()
bc(1): Use more .Ql, misc related fixes.


(uwe)
diff -r1.6 -r1.7 src/external/bsd/bc/dist/bc.1

cvs diff -r1.6 -r1.7 src/external/bsd/bc/dist/bc.1 (switch to unified diff)

--- src/external/bsd/bc/dist/bc.1 2021/01/07 20:37:33 1.6
+++ src/external/bsd/bc/dist/bc.1 2021/01/07 21:21:35 1.7
@@ -1,1317 +1,1340 @@ @@ -1,1317 +1,1340 @@
1.\" $NetBSD: bc.1,v 1.6 2021/01/07 20:37:33 uwe Exp $ 1.\" $NetBSD: bc.1,v 1.7 2021/01/07 21:21:35 uwe Exp $
2.\" 2.\"
3.\" bc.1 - the bc manual 3.\" bc.1 - the bc manual
4.\" 4.\"
5.\" Copyright (C) 1991-1994, 1997, 2000, 2003, 2012-2017 Free Software Foundation, Inc. 5.\" Copyright (C) 1991-1994, 1997, 2000, 2003, 2012-2017 Free Software Foundation, Inc.
6.\" Copyright (C) 2004, 2017 Philip A. Nelson 6.\" Copyright (C) 2004, 2017 Philip A. Nelson
7.\" Copyright (C) 2017 Thomas Klausner 7.\" Copyright (C) 2017 Thomas Klausner
8.\" All rights reserved. 8.\" All rights reserved.
9.\" 9.\"
10.\" Redistribution and use in source and binary forms, with or without 10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions 11.\" modification, are permitted provided that the following conditions
12.\" are met: 12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright 13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer. 14.\" notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in the 16.\" notice, this list of conditions and the following disclaimer in the
17.\" documentation and/or other materials provided with the distribution. 17.\" documentation and/or other materials provided with the distribution.
18.\" 3. Neither the name of Philip A. Nelson nor the name of the Free Software 18.\" 3. Neither the name of Philip A. Nelson nor the name of the Free Software
19.\" Foundation may not be used to endorse or promote products derived from 19.\" Foundation may not be used to endorse or promote products derived from
20.\" this software without specific prior written permission. 20.\" this software without specific prior written permission.
21.\" 21.\"
22.\" THIS SOFTWARE IS PROVIDED BY PHILIP A. NELSON ``AS IS'' AND ANY EXPRESS OR 22.\" THIS SOFTWARE IS PROVIDED BY PHILIP A. NELSON ``AS IS'' AND ANY EXPRESS OR
23.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25.\" IN NO EVENT SHALL PHILIP A. NELSON OR THE FREE SOFTWARE FOUNDATION BE 25.\" IN NO EVENT SHALL PHILIP A. NELSON OR THE FREE SOFTWARE FOUNDATION BE
26.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32.\" THE POSSIBILITY OF SUCH DAMAGE. 32.\" THE POSSIBILITY OF SUCH DAMAGE.
33.\" 33.\"
34.\" 34.\"
35.\" 35.\"
36.Dd April 16, 2017 36.Dd April 16, 2017
37.Dt BC 1 37.Dt BC 1
38.Os 38.Os
39.Sh NAME 39.Sh NAME
40.Nm bc 40.Nm bc
41.Nd arbitrary precision calculator language 41.Nd arbitrary precision calculator language
42.Sh SYNOPSIS 42.Sh SYNOPSIS
43.Nm 43.Nm
44.Op Fl hilqsvw 44.Op Fl hilqsvw
45.Op long-options 45.Op long-options
46.Op Ar 46.Op Ar
47.Sh DESCRIPTION 47.Sh DESCRIPTION
48.Nm 48.Nm
49is a language that supports arbitrary precision numbers 49is a language that supports arbitrary precision numbers
50with interactive execution of statements. 50with interactive execution of statements.
51There are some similarities 51There are some similarities
52in the syntax to the C programming language. 52in the syntax to the C programming language.
53A standard math library is available by command line option. 53A standard math library is available by command line option.
54If requested, the math library is defined before processing any files. 54If requested, the math library is defined before processing any files.
55.Nm 55.Nm
56starts by processing code from all the files listed 56starts by processing code from all the files listed
57on the command line in the order listed. 57on the command line in the order listed.
58After all files have been processed, 58After all files have been processed,
59.Nm 59.Nm
60reads from the standard input. 60reads from the standard input.
61All code is executed as it is read. 61All code is executed as it is read.
62(If a file contains a command to halt the processor, 62(If a file contains a command to halt the processor,
63.Nm 63.Nm
64will never read from the standard input.) 64will never read from the standard input.)
65.Pp 65.Pp
66This version of 66This version of
67.Nm 67.Nm
68contains several extensions beyond traditional 68contains several extensions beyond traditional
69.Nm 69.Nm
70implementations and the POSIX draft standard. 70implementations and the POSIX draft standard.
71Command line options can cause these extensions to print a warning 71Command line options can cause these extensions to print a warning
72or to be rejected. 72or to be rejected.
73This document describes the language accepted by this processor. 73This document describes the language accepted by this processor.
74Extensions will be identified as such. 74Extensions will be identified as such.
75.Ss OPTIONS 75.Ss OPTIONS
76.Bl -tag -width "XXinteractiveXXXXXX" 76.Bl -tag -width "XXinteractiveXXXXXX"
77.It Fl h , Fl Fl help 77.It Fl h , Fl Fl help
78Print the usage and exit. 78Print the usage and exit.
79.It Fl i , Fl Fl interactive 79.It Fl i , Fl Fl interactive
80Force interactive mode. 80Force interactive mode.
81.It Fl l , Fl Fl mathlib 81.It Fl l , Fl Fl mathlib
82Define the standard math library. 82Define the standard math library.
83.It Fl q , Fl Fl quiet 83.It Fl q , Fl Fl quiet
84Quiet mode. 84Quiet mode.
85.It Fl s , Fl Fl standard 85.It Fl s , Fl Fl standard
86Process exactly the POSIX 86Process exactly the POSIX
87.Nm 87.Nm
88language. 88language.
89.It Fl v , Fl Fl version 89.It Fl v , Fl Fl version
90Print the version number and copyright and quit. 90Print the version number and copyright and quit.
91.It Fl w , Fl Fl warn 91.It Fl w , Fl Fl warn
92Give warnings for extensions to POSIX 92Give warnings for extensions to POSIX
93.Nm . 93.Nm .
94.El 94.El
95.Ss NUMBERS 95.Ss NUMBERS
96The most basic element in 96The most basic element in
97.Nm 97.Nm
98is the number. 98is the number.
99Numbers are arbitrary precision numbers. 99Numbers are arbitrary precision numbers.
100This precision is both in the integer 100This precision is both in the integer
101part and the fractional part. 101part and the fractional part.
102All numbers are represented internally 102All numbers are represented internally
103in decimal and all computation is done in decimal. 103in decimal and all computation is done in decimal.
104(This version of 104(This version of
105.Nm 105.Nm
106truncates results from divide and multiply operations.) 106truncates results from divide and multiply operations.)
107There are two attributes of numbers, the length and the scale. 107There are two attributes of numbers, the length and the scale.
108The length is the 108The length is the
109total number of significant decimal digits in a number and the scale 109total number of significant decimal digits in a number and the scale
110is the total number of decimal digits after the decimal point. 110is the total number of decimal digits after the decimal point.
111For example: 111For example:
112.Pp 112.Pp
113.Bl -inset -offset indent -compact 113.Bl -inset -offset indent -compact
114.It Li .000001 114.It Li .000001
115has a length of 6 and scale of 6. 115has a length of 6 and scale of 6.
116.It Li 1935.000 116.It Li 1935.000
117has a length of 7 and a scale of 3. 117has a length of 7 and a scale of 3.
118.El 118.El
119.Ss VARIABLES 119.Ss VARIABLES
120Numbers are stored in two types of variables, simple variables and 120Numbers are stored in two types of variables, simple variables and
121arrays. 121arrays.
122Both simple variables and array variables are named. 122Both simple variables and array variables are named.
123Names begin with a letter followed by any number of letters, digits and 123Names begin with a letter followed by any number of letters, digits and
124underscores. 124underscores.
125All letters must be lower case. 125All letters must be lower case.
126(Full alpha-numeric names are an extension. 126(Full alpha-numeric names are an extension.
127In POSIX 127In POSIX
128.Nm 128.Nm
129all names are a single lower case letter.) 129all names are a single lower case letter.)
130The type of variable is clear by the context 130The type of variable is clear by the context
131because all array variable names will be followed by brackets ([]). 131because all array variable names will be followed by brackets
 132.Pq Ql [] .
132.Pp 133.Pp
133There are four special variables, 134There are four special variables,
134.Ic scale , 135.Ic scale ,
135.Ic ibase , 136.Ic ibase ,
136.Ic obase , 137.Ic obase ,
137and 138and
138.Ic last . 139.Ic last .
139.Ic scale 140.Ic scale
140defines how some operations use digits after the decimal point. 141defines how some operations use digits after the decimal point.
141The default value of 142The default value of
142.Ic scale 143.Ic scale
143is 0. 144is 0.
144.Ic ibase 145.Ic ibase
145and 146and
146.Ic obase 147.Ic obase
147define the conversion base for input and output numbers. 148define the conversion base for input and output numbers.
148The default for both input and output is base 10. 149The default for both input and output is base 10.
149.Ic last 150.Ic last
150(an extension) is a variable that has the value of the last 151(an extension) is a variable that has the value of the last
151printed number. 152printed number.
152These will be discussed in further detail where appropriate. 153These will be discussed in further detail where appropriate.
153All of these variables may have values assigned to them 154All of these variables may have values assigned to them
154as well as used in expressions. 155as well as used in expressions.
155.Ss COMMENTS 156.Ss COMMENTS
156Comments in 157Comments in
157.Nm 158.Nm
158start with the characters 159start with the characters
159.Dq Ic /* 160.Ql /*
160and end with the characters 161and end with the characters
161.Dq Ic */ . 162.Ql */ .
162Comments may start anywhere and appear as a single space in the input. 163Comments may start anywhere and appear as a single space in the input.
163(This causes comments to delimit other input items. 164(This causes comments to delimit other input items.
164For example, a comment can not be found in the middle of 165For example, a comment can not be found in the middle of
165a variable name.) 166a variable name.)
166Comments include any newlines (end of line) between 167Comments include any newlines (end of line) between
167the start and the end of the comment. 168the start and the end of the comment.
168.Pp 169.Pp
169To support the use of scripts for 170To support the use of scripts for
170.Nm , 171.Nm ,
171a single line comment has been added as an extension. 172a single line comment has been added as an extension.
172A single line comment starts at a 173A single line comment starts at a
173.Dq Ic # 174.Ql #
174character and continues to the next end of the line. 175character and continues to the next end of the line.
175The end of line 176The end of line
176character is not part of the comment and is processed normally. 177character is not part of the comment and is processed normally.
177.Ss EXPRESSIONS 178.Ss EXPRESSIONS
178The numbers are manipulated by expressions and statements. 179The numbers are manipulated by expressions and statements.
179Since the language was designed to be interactive, statements and expressions 180Since the language was designed to be interactive, statements and expressions
180are executed as soon as possible. 181are executed as soon as possible.
181There is no 182There is no
182.Dq main 183.Dq main
183program. 184program.
184Instead, code is executed as it is encountered. 185Instead, code is executed as it is encountered.
185(Functions, discussed in 186(Functions, discussed in
186detail later, are defined when encountered.) 187detail later, are defined when encountered.)
187.Pp 188.Pp
188A simple expression is just a constant. 189A simple expression is just a constant.
189.Nm 190.Nm
190converts constants 191converts constants
191into internal decimal numbers using the current input base, specified 192into internal decimal numbers using the current input base, specified
192by the variable 193by the variable
193.Ic ibase . 194.Ic ibase .
194(There is an exception in functions.) 195(There is an exception in functions.)
195The legal values of 196The legal values of
196.Ic ibase 197.Ic ibase
197are 2 through 36. 198are 2 through 36.
198(Base values greater than 16 are an extension.) 199(Base values greater than 16 are an extension.)
199Assigning a value outside this range to 200Assigning a value outside this range to
200.Ic ibase 201.Ic ibase
201will result in a value of 2 or 36. 202will result in a value of 2 or 36.
202Input numbers may contain the characters 0-9 and A-Z. 203Input numbers may contain the characters 0-9 and A-Z.
203(Note: They must be capitals. 204(Note: They must be capitals.
204Lower case letters are variable names.) 205Lower case letters are variable names.)
205Single digit numbers always 206Single digit numbers always
206have the value of the digit regardless of the value of 207have the value of the digit regardless of the value of
207.Ic ibase . 208.Ic ibase .
208(i.e. A = 10.) 209(i.e.\&
 210.Ql A
 211=\~10.)
209For multi-digit numbers, 212For multi-digit numbers,
210.Nm 213.Nm
211changes all input digits greater or equal to ibase to the value of 214changes all input digits greater or equal to ibase to the value of
212.Ic ibase - 1 . 215.Ic ibase - 1 .
213This makes the number 216This makes the number
214.Dq ZZZ 217.Ql ZZZ
215always be the largest 3 digit number of the input base. 218always be the largest 3 digit number of the input base.
216.Pp 219.Pp
217Full expressions are similar to many other high level languages. 220Full expressions are similar to many other high level languages.
218Since there is only one kind of number, there are no rules for mixing 221Since there is only one kind of number, there are no rules for mixing
219types. 222types.
220Instead, there are rules on the scale of expressions. 223Instead, there are rules on the scale of expressions.
221Every expression has a scale. 224Every expression has a scale.
222This is derived from the scale of original 225This is derived from the scale of original
223numbers, the operation performed and in many cases, the value of the 226numbers, the operation performed and in many cases, the value of the
224variable 227variable
225.Ic scale . 228.Ic scale .
226Legal values of the variable 229Legal values of the variable
227.Ic scale 230.Ic scale
228are 0 to the maximum number representable by a C integer. 231are 0 to the maximum number representable by a C integer.
229.Pp 232.Pp
230In the following descriptions of legal expressions, 233In the following descriptions of legal expressions,
231.Dq expr 234.Dq expr
232refers to a complete expression and 235refers to a complete expression and
233.Dq var 236.Dq var
234refers to a simple or an array variable. 237refers to a simple or an array variable.
235A simple variable is just a 238A simple variable is just a
236.Ic name 239.Ic name
237and an array variable is specified as 240and an array variable is specified as
238.Ic name[expr] . 241.Ic name[expr] .
239Unless specifically mentioned the scale of the result is the maximum scale of the 242Unless specifically mentioned the scale of the result is the maximum scale of the
240expressions involved. 243expressions involved.
241.Bl -tag -width 15n 244.Bl -tag -width 15n
242.It Ic "- expr" 245.It Ic "- expr"
243The result is the negation of the expression. 246The result is the negation of the expression.
244.It Ic "++ var" 247.It Ic "++ var"
245The variable is incremented by one and the new value is the result of 248The variable is incremented by one and the new value is the result of
246the expression. 249the expression.
247.It Ic "-- var" 250.It Ic "-- var"
248The variable is decremented by one and the new value is the result of the 251The variable is decremented by one and the new value is the result of the
249expression. 252expression.
250.It Ic "var ++" 253.It Ic "var ++"
251The result of the expression is the value of 254The result of the expression is the value of
252the variable and then the variable is incremented by one. 255the variable and then the variable is incremented by one.
253.It Ic "var --" 256.It Ic "var --"
254The result of the expression is the value of the variable and then 257The result of the expression is the value of the variable and then
255the variable is decremented by one. 258the variable is decremented by one.
256.It Ic "expr + expr" 259.It Ic "expr + expr"
257The result of the expression is the sum of the two expressions. 260The result of the expression is the sum of the two expressions.
258.It Ic "expr - expr" 261.It Ic "expr - expr"
259The result of the expression is the difference of the two expressions. 262The result of the expression is the difference of the two expressions.
260.It Ic "expr * expr" 263.It Ic "expr * expr"
261The result of the expression is the product of the two expressions. 264The result of the expression is the product of the two expressions.
262.It Ic "expr / expr" 265.It Ic "expr / expr"
263The result of the expression is the quotient of the two expressions. 266The result of the expression is the quotient of the two expressions.
264The scale of the result is the value of the variable \fBscale\fR. 267The scale of the result is the value of the variable \fBscale\fR.
265.It Ic "expr % expr" 268.It Ic "expr % expr"
266The result of the expression is the remainder and it is computed in the 269The result of the expression is the remainder and it is computed in the
267following way: 270following way:
268To compute a%b, first a/b is computed to 271To compute a%b, first a/b is computed to
269.Ic scale 272.Ic scale
270digits. 273digits.
271That result is used to compute a-(a/b)*b to the scale of the 274That result is used to compute a-(a/b)*b to the scale of the
272maximum of 275maximum of
273.Ic scale + 276.Ic scale +
274scale(b) and scale(a). 277scale(b) and scale(a).
275If 278If
276.Ic scale 279.Ic scale
277is set to zero and both expressions are integers this expression is the 280is set to zero and both expressions are integers this expression is the
278integer remainder function. 281integer remainder function.
279.It Ic "expr ^ expr" 282.It Ic "expr ^ expr"
280The result of the expression is the value of the first raised to the 283The result of the expression is the value of the first raised to the
281second. 284second.
282The second expression must be an integer. 285The second expression must be an integer.
283(If the second expression is not an integer, a warning is generated and the 286(If the second expression is not an integer, a warning is generated and the
284expression is truncated to get an integer value.) 287expression is truncated to get an integer value.)
285The scale of the result is 288The scale of the result is
286.Ic scale 289.Ic scale
287if the exponent is negative. 290if the exponent is negative.
288If the exponent is positive, the scale of the result is the minimum of 291If the exponent is positive, the scale of the result is the minimum of
289the scale of the first expression times the value of the exponent and 292the scale of the first expression times the value of the exponent and
290the maximum of 293the maximum of
291.Ic scale 294.Ic scale
292and the scale of the first expression. 295and the scale of the first expression.
293(e.g. scale(a^b) = min(scale(a)*b, max( 296(e.g. scale(a^b) = min(scale(a)*b, max(
294.Ic scale , 297.Ic scale ,
295scale(a))).) 298scale(a))).)
296It should be noted 299It should be noted
297that expr^0 will always return the value of 1. 300that expr^0 will always return the value of 1.
298.It Ic "( expr )" 301.It Ic "( expr )"
299This alters the standard precedence to force the evaluation of the 302This alters the standard precedence to force the evaluation of the
300expression. 303expression.
301.It Ic "var = expr" 304.It Ic "var = expr"
302The variable is assigned the value of the expression. 305The variable is assigned the value of the expression.
303.It Ic "var <op>= expr" 306.It Ic "var <op>= expr"
304This is equivalent to 307This is equivalent to
305.Ic "var = var <op> expr" 308.Ic "var = var <op> expr"
306with the exception that the 309with the exception that the
307.Dq Ic var 310.Dq Ic var
308part is evaluated only once. 311part is evaluated only once.
309This can make a difference if 312This can make a difference if
310.Dq Ic var 313.Dq Ic var
311is an array. 314is an array.
312.El 315.El
313.Pp 316.Pp
314Relational expressions are a special kind of expression 317Relational expressions are a special kind of expression
315that always evaluate to 0 or 1, 0 if the relation is false and 1 if 318that always evaluate to 0 or 1, 0 if the relation is false and 1 if
316the relation is true. 319the relation is true.
317These may appear in any legal expression. 320These may appear in any legal expression.
318(POSIX 321(POSIX
319.Nm 322.Nm
320requires that relational expressions are used only in 323requires that relational expressions are used only in
321.Ic if , 324.Ic if ,
322.Ic while , 325.Ic while ,
323and 326and
324.Ic for 327.Ic for
325statements and that only one relational test may be 328statements and that only one relational test may be
326done in them.) 329done in them.)
327The relational operators are: 330The relational operators are:
328.Bl -tag -width 15n 331.Bl -tag -width 15n
329.It Ic "expr1 < expr2" 332.It Ic "expr1 < expr2"
330The result is 1 if expr1 is strictly less than expr2. 333The result is 1 if expr1 is strictly less than expr2.
331.It Ic "expr1 <= expr2" 334.It Ic "expr1 <= expr2"
332The result is 1 if expr1 is less than or equal to expr2. 335The result is 1 if expr1 is less than or equal to expr2.
333.It Ic "expr1 > expr2" 336.It Ic "expr1 > expr2"
334The result is 1 if expr1 is strictly greater than expr2. 337The result is 1 if expr1 is strictly greater than expr2.
335.It Ic "expr1 >= expr2" 338.It Ic "expr1 >= expr2"
336The result is 1 if expr1 is greater than or equal to expr2. 339The result is 1 if expr1 is greater than or equal to expr2.
337.It Ic "expr1 == expr2" 340.It Ic "expr1 == expr2"
338The result is 1 if expr1 is equal to expr2. 341The result is 1 if expr1 is equal to expr2.
339.It Ic "expr1 != expr2" 342.It Ic "expr1 != expr2"
340The result is 1 if expr1 is not equal to expr2. 343The result is 1 if expr1 is not equal to expr2.
341.El 344.El
342.Pp 345.Pp
343Boolean operations are also legal. 346Boolean operations are also legal.
344(POSIX 347(POSIX
345.Nm 348.Nm
346does 349does
347.Em NOT 350.Em NOT
348have boolean operations.) 351have boolean operations.)
349The result of all boolean operations are 0 and 1 352The result of all boolean operations are 0 and 1
350(for false and true) as in relational expressions. 353(for false and true) as in relational expressions.
351The boolean 354The boolean
352operators are: 355operators are:
353.Bl -tag -width 15n 356.Bl -tag -width 15n
354.It Ic "!expr" 357.It Ic "!expr"
355The result is 1 if expr is 0. 358The result is 1 if expr is 0.
356.It Ic "expr && expr" 359.It Ic "expr && expr"
357The result is 1 if both expressions are non-zero. 360The result is 1 if both expressions are non-zero.
358.It Ic "expr || expr" 361.It Ic "expr || expr"
359The result is 1 if either expression is non-zero. 362The result is 1 if either expression is non-zero.
360.El 363.El
361.Pp 364.Pp
362The expression precedence is as follows: (lowest to highest) 365The expression precedence is as follows: (lowest to highest)
363.Bl -enum -offset indent 366.Bl -enum -offset indent
364.It 367.It
365|| operator, left associative 368.Ql ||
 369operator, left associative
366.It 370.It
367&& operator, left associative 371.Ql &&
 372operator, left associative
368.It 373.It
369! operator, nonassociative 374.Ql \&!
 375operator, nonassociative
370.It 376.It
371Relational operators, left associative 377Relational operators, left associative
372.It 378.It
373Assignment operator, right associative 379Assignment operator, right associative
374.It 380.It
375+ and - operators, left associative 381.Ql +
 382and
 383.Ql -
 384operators, left associative
376.It 385.It
377*, / and % operators, left associative 386.Ql * ,
 387.Ql /
 388and
 389.Ql %
 390operators, left associative
378.It 391.It
379^ operator, right associative 392.Ql ^
 393operator, right associative
380.It 394.It
381unary - operator, nonassociative 395unary
 396.Ql -
 397operator, nonassociative
382.It 398.It
383++ and -- operators, nonassociative 399.Ql ++
 400and
 401.Ql --
 402operators, nonassociative
384.El 403.El
385.Pp 404.Pp
386This precedence was chosen so that POSIX compliant 405This precedence was chosen so that POSIX compliant
387.Nm 406.Nm
388programs will run correctly. 407programs will run correctly.
389This will cause the use of the relational and logical operators to 408This will cause the use of the relational and logical operators to
390have some unusual behavior when used with assignment expressions. 409have some unusual behavior when used with assignment expressions.
391Consider the expression: 410Consider the expression:
392.Dl Ic a = 3 < 5 411.Dl a = 3 < 5
393.Pp 412.Pp
394Most C programmers would assume this would assign the result of 413Most C programmers would assume this would assign the result of
395.Dq Ic 3 < 5 414.Dq Li 3 < 5
396(the value 1) to the variable 415(the value 1) to the variable
397.Dq Ic a . 416.Va a .
398What this does in 417What this does in
399.Nm 418.Nm
400is assign the value 3 to the variable 419is assign the value 3 to the variable
401.Dq Ic a 420.Va a
402and then compare 3 to 5. 421and then compare 3 to 5.
403It is best to use parenthesis when using relational and logical operators 422It is best to use parenthesis when using relational and logical operators
404with the assignment operators. 423with the assignment operators.
405.Pp 424.Pp
406There are a few more special expressions that are provided in 425There are a few more special expressions that are provided in
407.Nm . 426.Nm .
408These have to do with user defined functions and standard functions. 427These have to do with user defined functions and standard functions.
409They all appear as 428They all appear as
410.Do Ar name ( Ar parameters ) Dc . 429.Do Ar name Ns Li \&( Ns Ar parameters Ns Li \&) Dc .
411See the section on functions for user defined functions. 430See the section on functions for user defined functions.
412The standard functions are: 431The standard functions are:
413.Bl -tag -width 20n 432.Bl -tag -width 20n
414.It Fn length expression 433.It Fn length expression
415The value of the length function is the number of significant digits in the 434The value of the length function is the number of significant digits in the
416expression. 435expression.
417.It Fn read 436.It Fn read
418The read function (an extension) will read a number from the standard 437The read function (an extension) will read a number from the standard
419input, regardless of where the function occurs. 438input, regardless of where the function occurs.
420Beware, this can cause problems with the mixing of data and program in 439Beware, this can cause problems with the mixing of data and program in
421the standard input. 440the standard input.
422The best use for this function is in a previously written program that 441The best use for this function is in a previously written program that
423needs input from the user, but never allows program code to be input 442needs input from the user, but never allows program code to be input
424from the user. 443from the user.
425The value of the read function is the number read from 444The value of the read function is the number read from
426the standard input using the current value of the variable 445the standard input using the current value of the variable
427.Ic ibase 446.Ic ibase
428for the conversion base. 447for the conversion base.
429.It Fn scale expression 448.It Fn scale expression
430The value of the scale function is the number of digits after the decimal 449The value of the scale function is the number of digits after the decimal
431point in the expression. 450point in the expression.
432.It Fn sqrt expression 451.It Fn sqrt expression
433The value of the sqrt function is the square root of the expression. 452The value of the sqrt function is the square root of the expression.
434If 453If
435the expression is negative, a run time error is generated. 454the expression is negative, a run time error is generated.
436.El 455.El
437.Ss STATEMENTS 456.Ss STATEMENTS
438Statements (as in most algebraic languages) provide the sequencing of 457Statements (as in most algebraic languages) provide the sequencing of
439expression evaluation. 458expression evaluation.
440In 459In
441.Nm 460.Nm
442statements are executed 461statements are executed
443.Dq as soon as possible . 462.Dq as soon as possible .
444Execution happens when a newline in encountered and 463Execution happens when a newline in encountered and
445there is one or more complete statements. 464there is one or more complete statements.
446Due to this immediate 465Due to this immediate
447execution, newlines are very important in 466execution, newlines are very important in
448.Nm . 467.Nm .
449In fact, both a 468In fact, both a
450semicolon and a newline are used as statement separators. 469semicolon and a newline are used as statement separators.
451An improperly placed newline will cause a syntax error. 470An improperly placed newline will cause a syntax error.
452Because newlines 471Because newlines
453are statement separators, it is possible to hide a newline by using 472are statement separators, it is possible to hide a newline by using
454the backslash character. 473the backslash character.
455The sequence 474The sequence
456.Dq Ic \e<nl> , 475.Dq Ic \e<nl> ,
457where <nl> is the newline appears to 476where <nl> is the newline appears to
458.Nm 477.Nm
459as whitespace instead of a newline. 478as whitespace instead of a newline.
460A statement list is a series of statements separated by semicolons and 479A statement list is a series of statements separated by semicolons and
461newlines. 480newlines.
462The following is a list of 481The following is a list of
463.Nm 482.Nm
464statements and what they do: 483statements and what they do:
465(Things enclosed in brackets ([]) are optional parts of the 484(Things enclosed in brackets
 485.Pq Oo Oc
 486are optional parts of the
466statement.) 487statement.)
467.Bl -tag -width 15n 488.Bl -tag -width 15n
468.It Ar expression 489.It Ar expression
469This statement does one of two things. 490This statement does one of two things.
470If the expression starts with 491If the expression starts with
471.Ao Ar variable Ac Ao Ar assignment Ac ... , 492.Ao Ar variable Ac Ao Ar assignment Ac ... ,
472it is considered to be an assignment statement. 493it is considered to be an assignment statement.
473If the expression is not an assignment statement, the 494If the expression is not an assignment statement, the
474expression is evaluated and printed to the output. 495expression is evaluated and printed to the output.
475After the number is printed, a newline is printed. 496After the number is printed, a newline is printed.
476For example, 497For example,
477.Dq Ic a=1 498.Dq Ic a=1
478is an assignment statement and 499is an assignment statement and
479.Do Ic ( a=1 ) Dc 500.Do Ic ( a=1 ) Dc
480is an expression that has an embedded assignment. 501is an expression that has an embedded assignment.
481All numbers that are printed are printed in the base 502All numbers that are printed are printed in the base
482specified by the variable 503specified by the variable
483.Ic obase . 504.Ic obase .
484The legal values for 505The legal values for
485.Ic obase 506.Ic obase
486are 2 through 507are 2 through
487.Dv BC_BASE_MAX . 508.Dv BC_BASE_MAX .
488(See the section 509(See the section
489.Sx LIMITS . ) 510.Sx LIMITS . )
490For bases 2 through 16, the usual method of writing numbers is used. 511For bases 2 through 16, the usual method of writing numbers is used.
491For bases greater than 16, 512For bases greater than 16,
492.Nm 513.Nm
493uses a multi-character digit method of printing the numbers where each 514uses a multi-character digit method of printing the numbers where each
494higher base digit is printed as a base 10 number. 515higher base digit is printed as a base 10 number.
495The multi-character digits are separated by spaces. 516The multi-character digits are separated by spaces.
496Each digit contains the number of characters required to represent the 517Each digit contains the number of characters required to represent the
497base ten value of 518base ten value of
498.Dq Ic obase-1 . 519.Dq Ic obase-1 .
499Since numbers are of arbitrary 520Since numbers are of arbitrary
500precision, some numbers may not be printable on a single output line. 521precision, some numbers may not be printable on a single output line.
501These long numbers will be split across lines using the 522These long numbers will be split across lines using the
502.Dq \e 523.Dq \e
503as the last character on a line. 524as the last character on a line.
504The maximum number of characters printed 525The maximum number of characters printed
505per line is 70. 526per line is 70.
506Due to the interactive nature of 527Due to the interactive nature of
507.Nm bc , 528.Nm bc ,
508printing a number causes the side effect of assigning the printed value to the 529printing a number causes the side effect of assigning the printed value to the
509special variable 530special variable
510.Ic last . 531.Ic last .
511This allows the user to recover the last value printed without having 532This allows the user to recover the last value printed without having
512to retype the expression that printed the number. 533to retype the expression that printed the number.
513Assigning to 534Assigning to
514.Ic last 535.Ic last
515is legal and will 536is legal and will
516overwrite the last printed value with the assigned value. 537overwrite the last printed value with the assigned value.
517The newly assigned value will remain until the next number is printed 538The newly assigned value will remain until the next number is printed
518or another value is assigned to 539or another value is assigned to
519.Ic last . 540.Ic last .
520(Some installations may allow the 541(Some installations may allow the
521use of a single period (.) which is not part of a number as a short 542use of a single period
522hand notation for 543.Pq Ql \&.
 544which is not part of a number as a short hand notation for
523.Ic last . ) 545.Ic last . )
524.It Ar "string" 546.It Ar "string"
525The 547The
526.Ar string 548.Ar string
527is printed to the output. 549is printed to the output.
528Strings start with a double quote 550Strings start with a double quote
529character and contain all characters until the next double quote character. 551character and contain all characters until the next double quote character.
530All characters are take literally, including any newline. 552All characters are take literally, including any newline.
531No newline character is printed after the string. 553No newline character is printed after the string.
532.It Ic print Ar list 554.It Ic print Ar list
533The 555The
534.Ic print 556.Ic print
535statement (an extension) provides another method of output. 557statement (an extension) provides another method of output.
536The 558The
537.Ar list 559.Ar list
538is a list of strings and expressions separated by commas. 560is a list of strings and expressions separated by commas.
539Each string or expression is printed in the order of the list. 561Each string or expression is printed in the order of the list.
540No terminating newline is printed. 562No terminating newline is printed.
541Expressions are evaluated and their 563Expressions are evaluated and their
542value is printed and assigned to the variable 564value is printed and assigned to the variable
543.Ic last . 565.Ic last .
544Strings in the 566Strings in the
545.Ic print 567.Ic print
546statement are printed to the output and may contain special characters. 568statement are printed to the output and may contain special characters.
547Special characters start with the backslash character (\e). 569Special characters start with the backslash character
 570.Pq Ql \e .
548The special characters recognized by 571The special characters recognized by
549.Nm 572.Nm
550are 573are
551.Sq a 574.Ql a
552(alert or bell), 575(alert or bell),
553.Sq b 576.Ql b
554(backspace), 577(backspace),
555.Sq f 578.Ql f
556(form feed), 579(form feed),
557.Sq n 580.Ql n
558(newline), 581(newline),
559.Sq r 582.Ql r
560(carriage return), 583(carriage return),
561.Sq q 584.Ql q
562(double quote), 585(double quote),
563.Sq t 586.Ql t
564(tab), and 587(tab), and
565.Sq \e 588.Ql \e
566(backslash). 589(backslash).
567Any other character following the backslash will be ignored. 590Any other character following the backslash will be ignored.
568.It { Ar statement_list } 591.It { Ar statement_list }
569This is the compound statement. 592This is the compound statement.
570It allows multiple statements to be grouped together for execution. 593It allows multiple statements to be grouped together for execution.
571.It Ic if ( Ar expression ) Ar statement1 [ Ic else Ar statement2 ] 594.It Ic if ( Ar expression ) Ar statement1 [ Ic else Ar statement2 ]
572The 595The
573.Ic if 596.Ic if
574statement evaluates the 597statement evaluates the
575.Ar expression 598.Ar expression
576and executes 599and executes
577.Ar statement1 600.Ar statement1
578or 601or
579.Ar statement2 602.Ar statement2
580depending on the value of the 603depending on the value of the
581.Ar expression . 604.Ar expression .
582If the 605If the
583.Ar expression 606.Ar expression
584is non-zero, 607is non-zero,
585.Ar statement1 608.Ar statement1
586is executed. 609is executed.
587If 610If
588.Ar statement2 611.Ar statement2
589is present and the value of the 612is present and the value of the
590.Ar expression 613.Ar expression
591is 0, then 614is 0, then
592.Ar statement2 615.Ar statement2
593is executed. 616is executed.
594(The 617(The
595.Ic else 618.Ic else
596clause is an extension.) 619clause is an extension.)
597.It Ic while ( Ar expression ) Ar statement 620.It Ic while ( Ar expression ) Ar statement
598The 621The
599.Ic while 622.Ic while
600statement will execute the 623statement will execute the
601.Ar statement 624.Ar statement
602while the 625while the
603.Ar expression 626.Ar expression
604is non-zero. 627is non-zero.
605It evaluates the 628It evaluates the
606.Ar expression 629.Ar expression
607before each execution of the 630before each execution of the
608.Ar statement . 631.Ar statement .
609Termination of the loop is caused by a zero 632Termination of the loop is caused by a zero
610.Ar expression 633.Ar expression
611value or the execution of a 634value or the execution of a
612.Ic break 635.Ic break
613statement. 636statement.
614.It Ic for ( [ Ar expression1 ] ; [ Ar expression2 ] ; [ Ar expression3 ] ) Ar statement 637.It Ic for ( [ Ar expression1 ] ; [ Ar expression2 ] ; [ Ar expression3 ] ) Ar statement
615The 638The
616.Ic for 639.Ic for
617statement controls repeated execution of the 640statement controls repeated execution of the
618.Ar statement . 641.Ar statement .
619.Ar Expression1 642.Ar Expression1
620is evaluated before the loop. 643is evaluated before the loop.
621.Ar Expression2 644.Ar Expression2
622is evaluated 645is evaluated
623before each execution of the 646before each execution of the
624.Ar statement . 647.Ar statement .
625If it is non-zero, the 648If it is non-zero, the
626.Ar statement 649.Ar statement
627is evaluated. 650is evaluated.
628If it is zero, the loop is terminated. 651If it is zero, the loop is terminated.
629After each execution of the statement, 652After each execution of the statement,
630.Ar expression3 653.Ar expression3
631is evaluated before the reevaluation of 654is evaluated before the reevaluation of
632.Ar expression2 . 655.Ar expression2 .
633If 656If
634.Ar expression1 657.Ar expression1
635or 658or
636.Ar expression3 659.Ar expression3
637are missing, nothing is evaluated at the point they would be evaluated. 660are missing, nothing is evaluated at the point they would be evaluated.
638If 661If
639.Ar expression2 662.Ar expression2
640is missing, it is the same as substituting the value 1 for 663is missing, it is the same as substituting the value 1 for
641.Ar expression2 . 664.Ar expression2 .
642(The optional expressions are an 665(The optional expressions are an
643extension. 666extension.
644POSIX 667POSIX
645.Nm 668.Nm
646requires all three expressions.) 669requires all three expressions.)
647The following is equivalent code for the 670The following is equivalent code for the
648.Ic for 671.Ic for
649statement: 672statement:
650.Bd -literal 673.Bd -literal -offset indent
651expression1; 674expression1;
652while (expression2) { 675while (expression2) {
653 statement; 676 statement;
654 expression3; 677 expression3;
655} 678}
656.Ed 679.Ed
657.It Ic break 680.It Ic break
658This statement causes a forced exit of the most recent enclosing 681This statement causes a forced exit of the most recent enclosing
659.Ic while 682.Ic while
660statement or 683statement or
661.Ic for 684.Ic for
662statement. 685statement.
663.It Ic continue 686.It Ic continue
664The 687The
665.Ic continue 688.Ic continue
666statement (an extension) causes the most recent enclosing 689statement (an extension) causes the most recent enclosing
667.Ic for 690.Ic for
668statement to start the next iteration. 691statement to start the next iteration.
669.It Ic halt 692.It Ic halt
670The 693The
671.Ic halt 694.Ic halt
672statement (an extension) is an executed statement that causes the 695statement (an extension) is an executed statement that causes the
673.Nm 696.Nm
674processor to quit only when it is executed. 697processor to quit only when it is executed.
675For example, 698For example,
676.Dl if (0 == 1) halt 699.Dl if (0 == 1) halt
677will not cause 700will not cause
678.Nm 701.Nm
679to terminate because the halt is not executed. 702to terminate because the halt is not executed.
680.It Ic return 703.It Ic return
681Return the value 0 from a function. 704Return the value 0 from a function.
682(See the section on functions.) 705(See the section on functions.)
683.It Ic return ( Ar expression ) 706.It Ic return ( Ar expression )
684Return the value of the expression from a function. 707Return the value of the expression from a function.
685(See the section on functions.) 708(See the section on functions.)
686As an extension, the parenthesis are not required. 709As an extension, the parenthesis are not required.
687.El 710.El
688.Ss PSEUDO STATEMENTS 711.Ss PSEUDO STATEMENTS
689These statements are not statements in the traditional sense. 712These statements are not statements in the traditional sense.
690They are not executed statements. 713They are not executed statements.
691Their function is performed at 714Their function is performed at
692.Dq compile 715.Dq compile
693time. 716time.
694.Bl -tag -width 15n 717.Bl -tag -width 15n
695.It Ic limits 718.It Ic limits
696Print the local limits enforced by the local version of 719Print the local limits enforced by the local version of
697.Nm 720.Nm
698This is an extension. 721This is an extension.
699.It Ic quit 722.It Ic quit
700When the 723When the
701.Ic quit 724.Ic quit
702statement is read, the 725statement is read, the
703.Nm 726.Nm
704processor 727processor
705is terminated, regardless of where the quit statement is found. 728is terminated, regardless of where the quit statement is found.
706For example, 729For example,
707.Dl if (0 == 1) quit 730.Dl if (0 == 1) quit
708will cause 731will cause
709.Nm 732.Nm
710to terminate. 733to terminate.
711.It Ic warranty 734.It Ic warranty
712Print a longer warranty notice. 735Print a longer warranty notice.
713This is an extension. 736This is an extension.
714.El 737.El
715.Ss FUNCTIONS 738.Ss FUNCTIONS
716Functions provide a method of defining a computation that can be executed 739Functions provide a method of defining a computation that can be executed
717later. 740later.
718Functions in 741Functions in
719.Nm 742.Nm
720always compute a value and return it to the caller. 743always compute a value and return it to the caller.
721Function definitions are 744Function definitions are
722.Dq dynamic 745.Dq dynamic
723in the sense that a function is 746in the sense that a function is
724undefined until a definition is encountered in the input. 747undefined until a definition is encountered in the input.
725That definition is then used until another 748That definition is then used until another
726definition function for the same name is encountered. 749definition function for the same name is encountered.
727The new definition then replaces the older definition. 750The new definition then replaces the older definition.
728A function is defined as follows: 751A function is defined as follows:
729.Bd -literal -offset indent 752.Bd -literal -offset indent
730define name ( parameters ) { newline 753define name ( parameters ) { newline
731 auto_list statement_list } 754 auto_list statement_list }
732.Ed 755.Ed
733.Pp 756.Pp
734A function call is just an expression of the form 757A function call is just an expression of the form
735.Do Ar name ( Ar parameters ) Dc . 758.Do Ar name ( Ar parameters ) Dc .
736.Pp 759.Pp
737Parameters are numbers or arrays (an extension). 760Parameters are numbers or arrays (an extension).
738In the function definition, zero or more parameters are defined by 761In the function definition, zero or more parameters are defined by
739listing their names separated by commas. 762listing their names separated by commas.
740All parameters are call by value parameters. 763All parameters are call by value parameters.
741Arrays are specified in the parameter definition by 764Arrays are specified in the parameter definition by
742the notation 765the notation
743.Do Ar name [ ] Dc . 766.Do Ar name [ ] Dc .
744In the function call, actual parameters 767In the function call, actual parameters
745are full expressions for number parameters. 768are full expressions for number parameters.
746The same notation is used 769The same notation is used
747for passing arrays as for defining array parameters. 770for passing arrays as for defining array parameters.
748The named array is passed by value to the function. 771The named array is passed by value to the function.
749Since function definitions are dynamic, 772Since function definitions are dynamic,
750parameter numbers and types are checked when a function is called. 773parameter numbers and types are checked when a function is called.
751Any mismatch in number or types of parameters will cause a runtime error. 774Any mismatch in number or types of parameters will cause a runtime error.
752A runtime error will also occur for the call to an undefined function. 775A runtime error will also occur for the call to an undefined function.
753.Pp 776.Pp
754The 777The
755.Ar auto_list 778.Ar auto_list
756is an optional list of variables that are for 779is an optional list of variables that are for
757.Dq local 780.Dq local
758use. 781use.
759The syntax of the auto list (if present) is 782The syntax of the auto list (if present) is
760.Do Ic auto Ar name , ... ; Dc . 783.Do Ic auto Ar name , ... ; Dc .
761(The semicolon is optional.) 784(The semicolon is optional.)
762Each 785Each
763.Ar name 786.Ar name
764is the name of an auto variable. 787is the name of an auto variable.
765Arrays may be specified by using the 788Arrays may be specified by using the
766same notation as used in parameters. 789same notation as used in parameters.
767These variables have their 790These variables have their
768values pushed onto a stack at the start of the function. 791values pushed onto a stack at the start of the function.
769The variables are then initialized to zero and used throughout the 792The variables are then initialized to zero and used throughout the
770execution of the function. 793execution of the function.
771At function exit, these variables are popped so that the original 794At function exit, these variables are popped so that the original
772value (at the time of the function call) of these variables are 795value (at the time of the function call) of these variables are
773restored. 796restored.
774The parameters are really auto variables that are initialized to a 797The parameters are really auto variables that are initialized to a
775value provided in the function call. 798value provided in the function call.
776Auto variables are different than traditional local variables 799Auto variables are different than traditional local variables
777because if function A calls function B, B may access function 800because if function A calls function B, B may access function
778A's auto variables by just using the same name, unless function B has 801A's auto variables by just using the same name, unless function B has
779called them auto variables. 802called them auto variables.
780Due to the fact that auto variables and parameters are pushed onto a 803Due to the fact that auto variables and parameters are pushed onto a
781stack, 804stack,
782.Nm 805.Nm
783supports recursive functions. 806supports recursive functions.
784.Pp 807.Pp
785The function body is a list of 808The function body is a list of
786.Nm 809.Nm
787statements. 810statements.
788Again, statements 811Again, statements
789are separated by semicolons or newlines. 812are separated by semicolons or newlines.
790Return statements cause the 813Return statements cause the
791termination of a function and the return of a value. 814termination of a function and the return of a value.
792There are two 815There are two
793versions of the return statement. 816versions of the return statement.
794The first form, 817The first form,
795.Dq Ic return , 818.Dq Ic return ,
796returns the value 0 to the calling expression. 819returns the value 0 to the calling expression.
797The second form, 820The second form,
798.Do Ic return ( Ar expression ) Dc , 821.Do Ic return ( Ar expression ) Dc ,
799computes the value of the expression 822computes the value of the expression
800and returns that value to the calling expression. 823and returns that value to the calling expression.
801There is an implied 824There is an implied
802.Do Ic return ( 0 ) Dc 825.Do Ic return ( 0 ) Dc
803at the end of every function. 826at the end of every function.
804This allows a function 827This allows a function
805to terminate and return 0 without an explicit return statement. 828to terminate and return 0 without an explicit return statement.
806.Pp 829.Pp
807Functions also change the usage of the variable 830Functions also change the usage of the variable
808.Ic ibase . 831.Ic ibase .
809All constants in the function body will be converted using the value of 832All constants in the function body will be converted using the value of
810.Ic ibase 833.Ic ibase
811at the time of the function call. 834at the time of the function call.
812Changes of 835Changes of
813.Ic ibase 836.Ic ibase
814will be ignored during the execution of the function except for the 837will be ignored during the execution of the function except for the
815standard function 838standard function
816.Fn read , 839.Fn read ,
817which will always use the current value 840which will always use the current value
818of 841of
819.Ic ibase 842.Ic ibase
820for conversion of numbers. 843for conversion of numbers.
821.Pp 844.Pp
822Several extensions have been added to functions. 845Several extensions have been added to functions.
823First, the format of the definition has been slightly relaxed. 846First, the format of the definition has been slightly relaxed.
824The standard requires the 847The standard requires the
825opening brace be on the same line as the 848opening brace be on the same line as the
826.Ic define 849.Ic define
827keyword and all other parts must be on following lines. 850keyword and all other parts must be on following lines.
828This version of 851This version of
829.Nm 852.Nm
830will allow any number of newlines before and after the opening brace of the 853will allow any number of newlines before and after the opening brace of the
831function. 854function.
832For example, the following definitions are legal. 855For example, the following definitions are legal.
833.Bd -literal -offset indent 856.Bd -literal -offset indent
834define d (n) { return (2*n); } 857define d (n) { return (2*n); }
835define d (n) 858define d (n)
836 { return (2*n); } 859 { return (2*n); }
837.Ed 860.Ed
838.Pp 861.Pp
839Functions may be defined as 862Functions may be defined as
840.Ic void . 863.Ic void .
841A 864A
842.Ic void 865.Ic void
843funtion returns no value and thus may not be used in any place that needs 866funtion returns no value and thus may not be used in any place that needs
844a value. 867a value.
845A 868A
846.Ic void 869.Ic void
847function does not produce any output when called by itself 870function does not produce any output when called by itself
848on an input line. 871on an input line.
849The key word 872The key word
850.Ic void 873.Ic void
851is placed between the key word 874is placed between the key word
852.Ic define 875.Ic define
853and the function name. 876and the function name.
854For example, consider the following session. 877For example, consider the following session.
855.Bd -literal -offset indent 878.Bd -literal -offset indent
856define py (y) { print "--->", y, "<---", "\n"; } 879define py (y) { print "--->", y, "<---", "\n"; }
857define void px (x) { print "--->", x, "<---", "\n"; } 880define void px (x) { print "--->", x, "<---", "\n"; }
858py(1) 881py(1)
859--->1<--- 882--->1<---
8600 8830
861px(1) 884px(1)
862--->1<--- 885--->1<---
863.Ed 886.Ed
864.Pp 887.Pp
865Since 888Since
866.Fn py 889.Fn py
867is not a void function, the call of 890is not a void function, the call of
868.Ql py(1) 891.Ql py(1)
869prints the desired output and then prints a second line that is the value of 892prints the desired output and then prints a second line that is the value of
870the function. 893the function.
871Since the value of a function that is not given an 894Since the value of a function that is not given an
872explicit return statement is zero, the zero is printed. 895explicit return statement is zero, the zero is printed.
873For 896For
874.Ql px(1) , 897.Ql px(1) ,
875no zero is printed because the function is a void function. 898no zero is printed because the function is a void function.
876.Pp 899.Pp
877Also, call by variable for arrays was added. 900Also, call by variable for arrays was added.
878To declare 901To declare
879a call by variable array, the declaration of the array parameter in the 902a call by variable array, the declaration of the array parameter in the
880function definition looks like 903function definition looks like
881.Do Fa name Ns Li [] Dc . 904.Do Fa name Ns Li [] Dc .
882The call to the 905The call to the
883function remains the same as call by value arrays. 906function remains the same as call by value arrays.
884.Ss MATH LIBRARY 907.Ss MATH LIBRARY
885If 908If
886.Nm 909.Nm
887is invoked with the 910is invoked with the
888.Fl l 911.Fl l
889option, a math library is preloaded and the default scale is set to 20. 912option, a math library is preloaded and the default scale is set to 20.
890The math functions will calculate their 913The math functions will calculate their
891results to the scale set at the time of their call. 914results to the scale set at the time of their call.
892The math library defines the following functions: 915The math library defines the following functions:
893.Bl -tag -width 15n 916.Bl -tag -width 15n
894.It Fn s x 917.It Fn s x
895The sine of 918The sine of
896.Fa x , 919.Fa x ,
897.Fa x 920.Fa x
898is in radians. 921is in radians.
899.It Fn c x 922.It Fn c x
900The cosine of 923The cosine of
901.Fa x , 924.Fa x ,
902.Fa x 925.Fa x
903is in radians. 926is in radians.
904.It Fn a x 927.It Fn a x
905The arctangent of 928The arctangent of
906.FA x , 929.FA x ,
907arctangent returns radians. 930arctangent returns radians.
908.It Fn l x 931.It Fn l x
909The natural logarithm of 932The natural logarithm of
910.Fa x . 933.Fa x .
911.It Fn e x 934.It Fn e x
912The exponential function of raising 935The exponential function of raising
913.Va e 936.Va e
914to the value 937to the value
915.Fa x . 938.Fa x .
916.It Fn j n x 939.It Fn j n x
917The Bessel function of integer order 940The Bessel function of integer order
918.Fa n 941.Fa n
919of 942of
920.Fa x . 943.Fa x .
921.El 944.El
922.Sh ENVIRONMENT 945.Sh ENVIRONMENT
923The following environment variables are processed by 946The following environment variables are processed by
924.Nm : 947.Nm :
925.Bl -tag -width 15n 948.Bl -tag -width 15n
926.It Ev POSIXLY_CORRECT 949.It Ev POSIXLY_CORRECT
927This is the same as the 950This is the same as the
928.Fl s 951.Fl s
929option. 952option.
930.It Dv BC_ENV_ARGS 953.It Dv BC_ENV_ARGS
931This is another mechanism to get arguments to 954This is another mechanism to get arguments to
932.Nm . 955.Nm .
933The format is the same as the command line arguments. 956The format is the same as the command line arguments.
934These arguments are processed first, so any files listed in the 957These arguments are processed first, so any files listed in the
935environment arguments are processed before any command line argument 958environment arguments are processed before any command line argument
936files. 959files.
937This allows the user to set up 960This allows the user to set up
938.Dq standard 961.Dq standard
939options and files to be 962options and files to be
940processed at every invocation of 963processed at every invocation of
941.Nm . 964.Nm .
942The files in the environment variables would typically contain 965The files in the environment variables would typically contain
943function definitions for functions the user wants defined every time 966function definitions for functions the user wants defined every time
944.Nm 967.Nm
945is run. 968is run.
946.It Dv BC_LINE_LENGTH 969.It Dv BC_LINE_LENGTH
947This should be an integer specifying the number of characters in an 970This should be an integer specifying the number of characters in an
948output line for numbers. 971output line for numbers.
949This includes the backslash and newline characters for long numbers. 972This includes the backslash and newline characters for long numbers.
950.El 973.El
951.Sh EXAMPLES 974.Sh EXAMPLES
952In 975In
953.Pa /bin/sh , 976.Pa /bin/sh ,
954the following will assign the value of 977the following will assign the value of
955.Ar pi 978.Ar pi
956to the shell variable 979to the shell variable
957.Ar pi . 980.Ar pi .
958.Bd -literal -offset indent 981.Bd -literal -offset indent
959pi=$(echo "scale=10; 4*a(1)" | bc -l) 982pi=$(echo "scale=10; 4*a(1)" | bc -l)
960.Ed 983.Ed
961.Pp 984.Pp
962The following is the definition of the exponential function used in the 985The following is the definition of the exponential function used in the
963math library. 986math library.
964This function is written in POSIX 987This function is written in POSIX
965.Nm . 988.Nm .
966.Bd -literal -offset indent 989.Bd -literal -offset indent
967scale = 20 990scale = 20
968 991
969/* Uses the fact that e^x = (e^(x/2))^2 992/* Uses the fact that e^x = (e^(x/2))^2
970 When x is small enough, we use the series: 993 When x is small enough, we use the series:
971 e^x = 1 + x + x^2/2! + x^3/3! + ... 994 e^x = 1 + x + x^2/2! + x^3/3! + ...
972*/ 995*/
973 996
974define e(x) { 997define e(x) {
975 auto a, d, e, f, i, m, v, z 998 auto a, d, e, f, i, m, v, z
976 999
977 /* Check the sign of x. */ 1000 /* Check the sign of x. */
978 if (x<0) { 1001 if (x<0) {
979 m = 1 1002 m = 1
980 x = -x 1003 x = -x
981 } 1004 }
982 1005
983 /* Precondition x. */ 1006 /* Precondition x. */
984 z = scale; 1007 z = scale;
985 scale = 4 + z + .44*x; 1008 scale = 4 + z + .44*x;
986 while (x > 1) { 1009 while (x > 1) {
987 f += 1; 1010 f += 1;
988 x /= 2; 1011 x /= 2;
989 } 1012 }
990 1013
991 /* Initialize the variables. */ 1014 /* Initialize the variables. */
992 v = 1+x 1015 v = 1+x
993 a = x 1016 a = x
994 d = 1 1017 d = 1
995 1018
996 for (i=2; 1; i++) { 1019 for (i=2; 1; i++) {
997 e = (a *= x) / (d *= i) 1020 e = (a *= x) / (d *= i)
998 if (e == 0) { 1021 if (e == 0) {
999 if (f>0) while (f--) v = v*v; 1022 if (f>0) while (f--) v = v*v;
1000 scale = z 1023 scale = z
1001 if (m) return (1/v); 1024 if (m) return (1/v);
1002 return (v/1); 1025 return (v/1);
1003 } 1026 }
1004 v += e 1027 v += e
1005 } 1028 }
1006} 1029}
1007.Ed 1030.Ed
1008.Pp 1031.Pp
1009The following is code that uses the extended features of 1032The following is code that uses the extended features of
1010.Nm 1033.Nm
1011to implement a simple program for calculating checkbook balances. 1034to implement a simple program for calculating checkbook balances.
1012This program is best kept in a file so that it can be used many times 1035This program is best kept in a file so that it can be used many times
1013without having to retype it at every use. 1036without having to retype it at every use.
1014.Bd -literal -offset indent 1037.Bd -literal -offset indent
1015scale=2 1038scale=2
1016print "\enCheck book program!\en" 1039print "\enCheck book program!\en"
1017print " Remember, deposits are negative transactions.\en" 1040print " Remember, deposits are negative transactions.\en"
1018print " Exit by a 0 transaction.\en\en" 1041print " Exit by a 0 transaction.\en\en"
1019 1042
1020print "Initial balance? "; bal = read() 1043print "Initial balance? "; bal = read()
1021bal /= 1 1044bal /= 1
1022print "\en" 1045print "\en"
1023while (1) { 1046while (1) {
1024 "current balance = "; bal 1047 "current balance = "; bal
1025 "transaction? "; trans = read() 1048 "transaction? "; trans = read()
1026 if (trans == 0) break; 1049 if (trans == 0) break;
1027 bal -= trans 1050 bal -= trans
1028 bal /= 1 1051 bal /= 1
1029} 1052}
1030quit 1053quit
1031.Ed 1054.Ed
1032.Pp 1055.Pp
1033The following is the definition of the recursive factorial function. 1056The following is the definition of the recursive factorial function.
1034.Bd -literal -offset indent 1057.Bd -literal -offset indent
1035define f (x) { 1058define f (x) {
1036 if (x <= 1) return (1); 1059 if (x <= 1) return (1);
1037 return (f(x-1) * x); 1060 return (f(x-1) * x);
1038} 1061}
1039.Ed 1062.Ed
1040.Ss EDITLINE OPTIONS 1063.Ss EDITLINE OPTIONS
1041.Nm 1064.Nm
1042is compiled using the 1065is compiled using the
1043.Xr editline 3 1066.Xr editline 3
1044library. 1067library.
1045This allows the user to do editing of lines before sending them 1068This allows the user to do editing of lines before sending them
1046to 1069to
1047.Nm . 1070.Nm .
1048It also allows for a history of previous lines typed. 1071It also allows for a history of previous lines typed.
1049This adds to 1072This adds to
1050.Nm 1073.Nm
1051one more special variable. 1074one more special variable.
1052This special variable, 1075This special variable,
1053.Ic history 1076.Ic history
1054is the number of lines of history retained. 1077is the number of lines of history retained.
1055The default value of \-1 means that an unlimited 1078The default value of \-1 means that an unlimited
1056number of history lines are retained. 1079number of history lines are retained.
1057Setting the value of 1080Setting the value of
1058.Ic history 1081.Ic history
1059to a positive number restricts the number of history 1082to a positive number restricts the number of history
1060lines to the number given. 1083lines to the number given.
1061The value of 0 disables the history feature. 1084The value of 0 disables the history feature.
1062For more information, read the user manual for the 1085For more information, read the user manual for the
1063.Xr editline 3 1086.Xr editline 3
1064library. 1087library.
1065.Ss DIFFERENCES 1088.Ss DIFFERENCES
1066This version of 1089This version of
1067.Nm 1090.Nm
1068was implemented from the POSIX P1003.2/D11 draft and contains 1091was implemented from the POSIX P1003.2/D11 draft and contains
1069several differences and extensions relative to the draft and 1092several differences and extensions relative to the draft and
1070traditional implementations. 1093traditional implementations.
1071It is not implemented in the traditional way using 1094It is not implemented in the traditional way using
1072.Xr dc 1 . 1095.Xr dc 1 .
1073This version is a single process which parses and runs a byte code 1096This version is a single process which parses and runs a byte code
1074translation of the program. 1097translation of the program.
1075There is an 1098There is an
1076.Dq undocumented 1099.Dq undocumented
1077option 1100option
1078.Fl ( c ) 1101.Fl ( c )
1079that causes the program to output the byte code to 1102that causes the program to output the byte code to
1080the standard output instead of running it. 1103the standard output instead of running it.
1081It was mainly used for 1104It was mainly used for
1082debugging the parser and preparing the math library. 1105debugging the parser and preparing the math library.
1083.Pp 1106.Pp
1084A major source of differences is extensions, where a feature is 1107A major source of differences is extensions, where a feature is
1085extended to add more functionality and additions, where new features 1108extended to add more functionality and additions, where new features
1086are added. 1109are added.
1087The following is the list of differences and extensions. 1110The following is the list of differences and extensions.
1088.Bl -tag -width 15n 1111.Bl -tag -width 15n
1089.It Ev LANG No environment 1112.It Ev LANG No environment
1090This version does not conform to the POSIX standard in the processing 1113This version does not conform to the POSIX standard in the processing
1091of the 1114of the
1092.Ev LANG 1115.Ev LANG
1093environment variable and all environment variables starting 1116environment variable and all environment variables starting
1094with 1117with
1095.Ev LC_ . 1118.Ev LC_ .
1096.It names 1119.It names
1097Traditional and POSIX 1120Traditional and POSIX
1098.Nm 1121.Nm
1099have single letter names for functions, variables and arrays. 1122have single letter names for functions, variables and arrays.
1100They have been extended to be multi-character names that start with a letter and 1123They have been extended to be multi-character names that start with a letter and
1101may contain letters, numbers and the underscore character. 1124may contain letters, numbers and the underscore character.
1102.It strings 1125.It strings
1103Strings are not allowed to contain NUL characters. 1126Strings are not allowed to contain NUL characters.
1104POSIX says all characters must be included in strings. 1127POSIX says all characters must be included in strings.
1105.It Ic last 1128.It Ic last
1106POSIX 1129POSIX
1107.Nm 1130.Nm
1108does not have a 1131does not have a
1109.Ic last 1132.Ic last
1110variable. 1133variable.
1111Some implementations 1134Some implementations
1112of 1135of
1113.Nm 1136.Nm
1114use the period 1137use the period
1115.Pq Ql \&. 1138.Pq Ql \&.
1116in a similar way. 1139in a similar way.
1117.It comparisons 1140.It comparisons
1118POSIX 1141POSIX
1119.Nm 1142.Nm
1120allows comparisons only in the 1143allows comparisons only in the
1121.Ic if 1144.Ic if
1122statement, the 1145statement, the
1123.Ic while 1146.Ic while
1124statement, and the second expression of the 1147statement, and the second expression of the
1125.Ic for 1148.Ic for
1126statement. 1149statement.
1127Also, only one relational operation is allowed in each of those statements. 1150Also, only one relational operation is allowed in each of those statements.
1128.It Ic if No statement , Ic else No clause 1151.It Ic if No statement , Ic else No clause
1129POSIX 1152POSIX
1130.Nm 1153.Nm
1131does not have an 1154does not have an
1132.Ic else 1155.Ic else
1133clause. 1156clause.
1134.It Ic for No statement 1157.It Ic for No statement
1135POSIX 1158POSIX
1136.Nm 1159.Nm
1137requires all expressions to be present in the 1160requires all expressions to be present in the
1138.Ic for 1161.Ic for
1139statement. 1162statement.
1140.It Li && , || , \&! 1163.It Li && , || , \&!
1141POSIX 1164POSIX
1142.Nm 1165.Nm
1143does not have the logical operators. 1166does not have the logical operators.
1144.It Ic read No function 1167.It Ic read No function
1145POSIX 1168POSIX
1146.Nm 1169.Nm
1147does not have a 1170does not have a
1148.Ic read 1171.Ic read
1149function. 1172function.
1150.It Ic print No statement 1173.It Ic print No statement
1151POSIX 1174POSIX
1152.Nm 1175.Nm
1153does not have a 1176does not have a
1154.Ic print 1177.Ic print
1155statement . 1178statement .
1156.It Ic continue No statement 1179.It Ic continue No statement
1157POSIX 1180POSIX
1158.Nm 1181.Nm
1159does not have a 1182does not have a
1160.Ic continue 1183.Ic continue
1161statement. 1184statement.
1162.It Ic return No statement 1185.It Ic return No statement
1163POSIX 1186POSIX
1164.Nm 1187.Nm
1165requires parentheses around the return expression. 1188requires parentheses around the return expression.
1166.It array parameters 1189.It array parameters
1167POSIX 1190POSIX
1168.Nm 1191.Nm
1169does not (currently) support array parameters in full. 1192does not (currently) support array parameters in full.
1170The POSIX grammar allows for arrays in function definitions, but does 1193The POSIX grammar allows for arrays in function definitions, but does
1171not provide a method to specify an array as an actual parameter. 1194not provide a method to specify an array as an actual parameter.
1172(This is most likely an oversight in the grammar.) 1195(This is most likely an oversight in the grammar.)
1173Traditional implementations of 1196Traditional implementations of
1174.Nm 1197.Nm
1175have only call-by-value array parameters. 1198have only call-by-value array parameters.
1176.It function format 1199.It function format
1177POSIX 1200POSIX
1178.Nm 1201.Nm
1179requires the opening brace on the same line as the 1202requires the opening brace on the same line as the
1180.Ic define 1203.Ic define
1181key word and the 1204key word and the
1182.Ic auto 1205.Ic auto
1183statement on the next line. 1206statement on the next line.
1184.It Li =+ , =- , =* , =/ , =% , =^ 1207.It Li =+ , =- , =* , =/ , =% , =^
1185POSIX 1208POSIX
1186.Nm 1209.Nm
1187does not require these 1210does not require these
1188.Dq old style 1211.Dq old style
1189assignment operators to be defined. 1212assignment operators to be defined.
1190This version may allow these 1213This version may allow these
1191.Dq old style 1214.Dq old style
1192assignments. 1215assignments.
1193Use the 1216Use the
1194.Ic limits 1217.Ic limits
1195statement to see if the installed version supports them. 1218statement to see if the installed version supports them.
1196If it does support the 1219If it does support the
1197.Dq old style 1220.Dq old style
1198assignment operators, the statement 1221assignment operators, the statement
1199.Dq Li a =- 1 1222.Dq Li a =- 1
1200will decrement 1223will decrement
1201.Va a 1224.Va a
1202by 1 instead of setting 1225by 1 instead of setting
1203.Va a 1226.Va a
1204to the value \-1. 1227to the value \-1.
1205.It spaces in numbers 1228.It spaces in numbers
1206Other implementations of 1229Other implementations of
1207.Nm 1230.Nm
1208allow spaces in numbers. 1231allow spaces in numbers.
1209For example, 1232For example,
1210.Dq Li x=1 3 1233.Dq Li x=1 3
1211would assign the value 13 to the variable 1234would assign the value 13 to the variable
1212.Va x . 1235.Va x .
1213The same statement 1236The same statement
1214would cause a syntax error in this version of 1237would cause a syntax error in this version of
1215.Nm . 1238.Nm .
1216.It errors and execution 1239.It errors and execution
1217This implementation varies from other implementations in terms of what 1240This implementation varies from other implementations in terms of what
1218code will be executed when syntax and other errors are found in the 1241code will be executed when syntax and other errors are found in the
1219program. 1242program.
1220If a syntax error is found in a function definition, error 1243If a syntax error is found in a function definition, error
1221recovery tries to find the beginning of a statement and continue to 1244recovery tries to find the beginning of a statement and continue to
1222parse the function. 1245parse the function.
1223Once a syntax error is found in the function, the 1246Once a syntax error is found in the function, the
1224function will not be callable and becomes undefined. 1247function will not be callable and becomes undefined.
1225Syntax errors in the interactive execution code will invalidate the 1248Syntax errors in the interactive execution code will invalidate the
1226current execution block. 1249current execution block.
1227The execution block is terminated by an 1250The execution block is terminated by an
1228end of line that appears after a complete sequence of statements. 1251end of line that appears after a complete sequence of statements.
1229For example, 1252For example,
1230.Bd -literal 1253.Bd -literal
1231a = 1 1254a = 1
1232b = 2 1255b = 2
1233.Ed 1256.Ed
1234has two execution blocks and 1257has two execution blocks and
1235.Bd -literal 1258.Bd -literal
1236{ a = 1 1259{ a = 1
1237 b = 2 } 1260 b = 2 }
1238.Ed 1261.Ed
1239has one execution block. 1262has one execution block.
1240Any runtime error will terminate the execution 1263Any runtime error will terminate the execution
1241of the current execution block. 1264of the current execution block.
1242A runtime warning will not terminate the current execution block. 1265A runtime warning will not terminate the current execution block.
1243.It interrupts 1266.It interrupts
1244During an interactive session, the 1267During an interactive session, the
1245.Dv SIGINT 1268.Dv SIGINT
1246signal (usually generated by the control-C character from the 1269signal (usually generated by the control-C character from the
1247terminal) will cause execution of the current execution block to be 1270terminal) will cause execution of the current execution block to be
1248interrupted. 1271interrupted.
1249It will display a 1272It will display a
1250.Dq runtime 1273.Dq runtime
1251error indicating which function was interrupted. 1274error indicating which function was interrupted.
1252After all runtime structures have been cleaned up, a message will be 1275After all runtime structures have been cleaned up, a message will be
1253printed to notify the user that 1276printed to notify the user that
1254.Nm 1277.Nm
1255is ready for more input. 1278is ready for more input.
1256All previously defined functions remain defined and the value of all 1279All previously defined functions remain defined and the value of all
1257non-auto variables are the value at the point of interruption. 1280non-auto variables are the value at the point of interruption.
1258All auto variables and function parameters are removed during the 1281All auto variables and function parameters are removed during the
1259clean up process. 1282clean up process.
1260During a non-interactive session, the 1283During a non-interactive session, the
1261.Dv SIGINT 1284.Dv SIGINT
1262signal will terminate the entire run of 1285signal will terminate the entire run of
1263.Nm . 1286.Nm .
1264.El 1287.El
1265.Ss LIMITS 1288.Ss LIMITS
1266The following are the limits currently in place for this 1289The following are the limits currently in place for this
1267.Nm 1290.Nm
1268processor. 1291processor.
1269Some of them may have been changed by an installation. 1292Some of them may have been changed by an installation.
1270Use the 1293Use the
1271.Ic limits 1294.Ic limits
1272statement to see the actual values. 1295statement to see the actual values.
1273.Bl -tag -width 15n 1296.Bl -tag -width 15n
1274.It Dv BC_BASE_MAX 1297.It Dv BC_BASE_MAX
1275The maximum output base is currently set at 999. 1298The maximum output base is currently set at 999.
1276The maximum input base is 16. 1299The maximum input base is 16.
1277.It Dv BC_DIM_MAX 1300.It Dv BC_DIM_MAX
1278This is currently an arbitrary limit of 65535 as distributed. 1301This is currently an arbitrary limit of 65535 as distributed.
1279Your installation may be different. 1302Your installation may be different.
1280.It Dv BC_SCALE_MAX 1303.It Dv BC_SCALE_MAX
1281The number of digits after the decimal point is limited to 1304The number of digits after the decimal point is limited to
1282.Dv INT_MAX 1305.Dv INT_MAX
1283digits. 1306digits.
1284Also, the number of digits before the decimal point is limited to 1307Also, the number of digits before the decimal point is limited to
1285.Dv INT_MAX 1308.Dv INT_MAX
1286digits. 1309digits.
1287.It Dv BC_STRING_MAX 1310.It Dv BC_STRING_MAX
1288The limit on the number of characters in a string is 1311The limit on the number of characters in a string is
1289.Dv INT_MAX 1312.Dv INT_MAX
1290characters. 1313characters.
1291.It exponent 1314.It exponent
1292The value of the exponent in the raise operation 1315The value of the exponent in the raise operation
1293.Pq Ql ^ 1316.Pq Ql ^
1294is limited to 1317is limited to
1295.Dv LONG_MAX . 1318.Dv LONG_MAX .
1296.It variable names 1319.It variable names
1297The current limit on the number of unique names is 32767 for each of 1320The current limit on the number of unique names is 32767 for each of
1298simple variables, arrays and functions. 1321simple variables, arrays and functions.
1299.El 1322.El
1300.Sh DIAGNOSTICS 1323.Sh DIAGNOSTICS
1301If any file on the command line can not be opened, 1324If any file on the command line can not be opened,
1302.Nm 1325.Nm
1303will report 1326will report
1304that the file is unavailable and terminate. 1327that the file is unavailable and terminate.
1305Also, there are compile 1328Also, there are compile
1306and run time diagnostics that should be self-explanatory. 1329and run time diagnostics that should be self-explanatory.
1307.Sh HISTORY 1330.Sh HISTORY
1308This man page documents bc version nb1.0. 1331This man page documents bc version nb1.0.
1309.Sh AUTHORS 1332.Sh AUTHORS
1310.An Philip A. Nelson Aq Mt phil@NetBSD.org 1333.An Philip A. Nelson Aq Mt phil@NetBSD.org
1311.Ss ACKNOWLEDGEMENTS 1334.Ss ACKNOWLEDGEMENTS
1312The author would like to thank Steve Sommars for his extensive help in 1335The author would like to thank Steve Sommars for his extensive help in
1313testing the implementation. 1336testing the implementation.
1314Many great suggestions were given. 1337Many great suggestions were given.
1315This is a much better product due to his involvement. 1338This is a much better product due to his involvement.
1316.Sh BUGS 1339.Sh BUGS
1317Error recovery is not very good yet. 1340Error recovery is not very good yet.