Lines Matching +full:- +full:r
2 .\" SPDX-License-Identifier: BSD-2-Clause
4 .\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
31 bc - arbitrary-precision decimal arithmetic language and calculator
34 \f[B]bc\f[R] [\f[B]-ghilPqRsvVw\f[R]] [\f[B]--global-stacks\f[R]]
35 [\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
36 [\f[B]--no-prompt\f[R]] [\f[B]--no-read-prompt\f[R]] [\f[B]--quiet\f[R]]
37 [\f[B]--standard\f[R]] [\f[B]--warn\f[R]] [\f[B]--version\f[R]]
38 [\f[B]-e\f[R] \f[I]expr\f[R]] [\f[B]--expression\f[R]=\f[I]expr\f[R]...]
39 [\f[B]-f\f[R] \f[I]file\f[R]...] [\f[B]--file\f[R]=\f[I]file\f[R]...]
40 [\f[I]file\f[R]...]
48 somewhat C-like, but there are differences.
52 the command line and executes them before reading from \f[B]stdin\f[R].
54 This bc(1) is a drop-in replacement for \f[I]any\f[R] bc(1), including
60 \f[B]-g\f[R], \f[B]--global-stacks\f[R]
99 alias d2o=\[dq]bc -e ibase=A -e obase=8\[dq]
100 alias h2b=\[dq]bc -e ibase=G -e obase=2\[dq]
111 If **-s**, **-w**, or any equivalents are used, this option is ignored.
113 This is a **non-portable extension**.
114 \f[R]
117 \f[B]-h\f[R], \f[B]--help\f[R]
121 \f[B]-i\f[R], \f[B]--interactive\f[R]
124 (See the \f[B]INTERACTIVE MODE\f[R] section.)
128 This is a **non-portable extension**.
129 \f[R]
132 \f[B]-l\f[R], \f[B]--mathlib\f[R]
134 : Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to
135 \f[B]20\f[R] and loads the included math library before running any
141 \f[R]
144 \f[B]-P\f[R], \f[B]--no-prompt\f[R]
148 See the \f[B]TTY MODE\f[R] section.) This is mostly for those users that
151 \f[B]BC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
155 This is a **non-portable extension**.
156 \f[R]
159 \f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
163 See the \f[B]TTY MODE\f[R] section.) This is mostly for those users that
166 \f[B]BC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
173 only used when the **read()** built-in function is called.
175 This is a **non-portable extension**.
176 \f[R]
179 \f[B]-q\f[R], \f[B]--quiet\f[R]
182 bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
185 \f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
189 This is a **non-portable extension**.
190 \f[R]
193 \f[B]-s\f[R], \f[B]--standard\f[R]
201 This is a **non-portable extension**.
202 \f[R]
205 \f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
211 This is a **non-portable extension**.
212 \f[R]
215 \f[B]-w\f[R], \f[B]--warn\f[R]
217 : Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
218 not errors) are printed for non-standard extensions and execution
223 This is a **non-portable extension**.
224 \f[R]
227 \f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
229 : Evaluates \f[I]expr\f[R].
238 If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
240 expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
241 as an argument at least once to **-f** or **-\[rs]-file**, whether on the
242 command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
243 **-\[rs]-expression**, **-f**, or **-\[rs]-file** arguments are given after **-f-**
246 This is a **non-portable extension**.
247 \f[R]
250 \f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
252 : Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
253 were read through \f[B]stdin\f[R].
259 If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
261 expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
262 as an argument at least once to **-f** or **-\[rs]-file**. However, if any other
263 **-e**, **-\[rs]-expression**, **-f**, or **-\[rs]-file** arguments are given after
264 **-f-** or equivalent is given, bc(1) will give a fatal error and exit.
266 This is a **non-portable extension**.
267 \f[R]
270 All long options are \f[B]non-portable extensions\f[R].
273 Any non-error output is written to \f[B]stdout\f[R].
274 In addition, if history (see the \f[B]HISTORY\f[R] section) and the
275 prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
276 to \f[B]stdout\f[R].
278 \f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
279 issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
280 write to \f[B]stdout\f[R], so if \f[B]stdout\f[R] is closed, as in
281 \f[B]bc >&-\f[R], it will quit with an error.
282 This is done so that bc(1) can report problems when \f[B]stdout\f[R] is
287 redirect \f[B]stdout\f[R] to \f[B]/dev/null\f[R].
290 Any error output is written to \f[B]stderr\f[R].
292 \f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
293 issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
294 write to \f[B]stderr\f[R], so if \f[B]stderr\f[R] is closed, as in
295 \f[B]bc 2>&-\f[R], it will quit with an error.
297 \f[B]stderr\f[R] is redirected to a file.
301 redirect \f[B]stderr\f[R] to \f[B]/dev/null\f[R].
304 The syntax for bc(1) programs is mostly C-like, with some differences.
312 In the sections below, \f[B]E\f[R] means expression, \f[B]S\f[R] means
313 statement, and \f[B]I\f[R] means identifier.
315 Identifiers (\f[B]I\f[R]) start with a lowercase letter and can be
316 followed by any number (up to \f[B]BC_NAME_MAX-1\f[R]) of lowercase
317 letters (\f[B]a-z\f[R]), digits (\f[B]0-9\f[R]), and underscores
318 (\f[B]_\f[R]).
319 The regex is \f[B][a-z][a-z0-9_]*\f[R].
321 \f[B]non-portable extension\f[R].
323 \f[B]ibase\f[R] is a global variable determining how to interpret
327 \f[B]ibase\f[R] is initially \f[B]10\f[R].
328 If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
329 (\f[B]--warn\f[R]) flags were not given on the command line, the max
330 allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
331 Otherwise, it is \f[B]16\f[R].
332 The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
333 The max allowable value for \f[B]ibase\f[R] can be queried in bc(1)
334 programs with the \f[B]maxibase()\f[R] built-in function.
336 \f[B]obase\f[R] is a global variable determining how to output results.
339 \f[B]obase\f[R] is initially \f[B]10\f[R].
340 The max allowable value for \f[B]obase\f[R] is \f[B]BC_BASE_MAX\f[R] and
341 can be queried in bc(1) programs with the \f[B]maxobase()\f[R] built-in
343 The min allowable value for \f[B]obase\f[R] is \f[B]2\f[R].
346 The \f[I]scale\f[R] of an expression is the number of digits in the
347 result of the expression right of the decimal point, and \f[B]scale\f[R]
350 \f[B]scale\f[R] is initially \f[B]0\f[R].
351 \f[B]scale\f[R] cannot be negative.
352 The max allowable value for \f[B]scale\f[R] is \f[B]BC_SCALE_MAX\f[R]
353 and can be queried in bc(1) programs with the \f[B]maxscale()\f[R]
354 built-in function.
356 bc(1) has both \f[I]global\f[R] variables and \f[I]local\f[R] variables.
357 All \f[I]local\f[R] variables are local to the function; they are
358 parameters or are introduced in the \f[B]auto\f[R] list of a function
359 (see the \f[B]FUNCTIONS\f[R] section).
361 \f[B]auto\f[R] list, it is assumed to be \f[I]global\f[R].
362 If a parent function has a \f[I]local\f[R] variable version of a
363 variable that a child function considers \f[I]global\f[R], the value of
364 that \f[I]global\f[R] variable in the child function is the value of the
366 \f[I]global\f[R] variable.
372 operator is an assignment operator \f[I]and\f[R] the expression is
376 \f[B]last\f[R].
377 A single dot (\f[B].\f[R]) may also be used as a synonym for
378 \f[B]last\f[R].
379 These are \f[B]non-portable extensions\f[R].
386 Block comments are enclosed in \f[B]/*\f[R] and \f[B]*/\f[R].
388 Line comments go from \f[B]#\f[R] until, and not including, the next
390 This is a \f[B]non-portable extension\f[R].
395 Variables: \f[B]I\f[R]
397 Array Elements: \f[B]I[E]\f[R]
399 \f[B]ibase\f[R]
401 \f[B]obase\f[R]
403 \f[B]scale\f[R]
405 \f[B]last\f[R] or a single dot (\f[B].\f[R])
407 Number 6 is a \f[B]non-portable extension\f[R].
411 This also applies to functions (see the \f[B]FUNCTIONS\f[R] section), so
417 \f[B]increment\f[R]/\f[B]decrement\f[R] operators and as the left side
418 of \f[B]assignment\f[R] operators (see the \f[I]Operators\f[R]
424 Numbers (see the \f[I]Numbers\f[R] subsection below).
426 Array indices (\f[B]I[E]\f[R]).
428 \f[B](E)\f[R]: The value of \f[B]E\f[R] (used to change precedence).
430 \f[B]sqrt(E)\f[R]: The square root of \f[B]E\f[R].
431 \f[B]E\f[R] must be non-negative.
433 \f[B]length(E)\f[R]: The number of significant decimal digits in
434 \f[B]E\f[R].
436 \f[B]length(I[])\f[R]: The number of elements in the array \f[B]I\f[R].
437 This is a \f[B]non-portable extension\f[R].
439 \f[B]scale(E)\f[R]: The \f[I]scale\f[R] of \f[B]E\f[R].
441 \f[B]abs(E)\f[R]: The absolute value of \f[B]E\f[R].
442 This is a \f[B]non-portable extension\f[R].
444 \f[B]I()\f[R], \f[B]I(E)\f[R], \f[B]I(E, E)\f[R], and so on, where
445 \f[B]I\f[R] is an identifier for a non-\f[B]void\f[R] function (see the
446 \f[I]Void Functions\f[R] subsection of the \f[B]FUNCTIONS\f[R] section).
447 The \f[B]E\f[R] argument(s) may also be arrays of the form
448 \f[B]I[]\f[R], which will automatically be turned into array references
449 (see the \f[I]Array References\f[R] subsection of the
450 \f[B]FUNCTIONS\f[R] section) if the corresponding parameter in the
453 \f[B]read()\f[R]: Reads a line from \f[B]stdin\f[R] and uses that as an
455 The result of that expression is the result of the \f[B]read()\f[R]
457 This is a \f[B]non-portable extension\f[R].
459 \f[B]maxibase()\f[R]: The max allowable \f[B]ibase\f[R].
460 This is a \f[B]non-portable extension\f[R].
462 \f[B]maxobase()\f[R]: The max allowable \f[B]obase\f[R].
463 This is a \f[B]non-portable extension\f[R].
465 \f[B]maxscale()\f[R]: The max allowable \f[B]scale\f[R].
466 This is a \f[B]non-portable extension\f[R].
470 \f[B]1\f[R] period for a radix.
471 Numbers can have up to \f[B]BC_NUM_MAX\f[R] digits.
472 Uppercase letters are equal to \f[B]9\f[R] + their position in the
473 alphabet (i.e., \f[B]A\f[R] equals \f[B]10\f[R], or \f[B]9+1\f[R]).
475 \f[B]ibase\f[R], they are set to the value of the highest valid digit in
476 \f[B]ibase\f[R].
478 Single-character numbers (i.e., \f[B]A\f[R] alone) take the value that
480 \f[B]ibase\f[R].
481 This means that \f[B]A\f[R] alone always equals decimal \f[B]10\f[R] and
482 \f[B]Z\f[R] alone always equals decimal \f[B]35\f[R].
489 \f[B]++\f[R] \f[B]--\f[R]
498 \f[R]
501 \f[B]-\f[R] \f[B]!\f[R]
510 \f[R]
513 \f[B]\[ha]\f[R]
522 \f[R]
525 \f[B]*\f[R] \f[B]/\f[R] \f[B]%\f[R]
534 \f[R]
537 \f[B]+\f[R] \f[B]-\f[R]
546 \f[R]
549 \f[B]=\f[R] \f[B]+=\f[R] \f[B]-=\f[R] \f[B]*=\f[R] \f[B]/=\f[R]
550 \f[B]%=\f[R] \f[B]\[ha]=\f[R]
559 \f[R]
562 \f[B]==\f[R] \f[B]<=\f[R] \f[B]>=\f[R] \f[B]!=\f[R] \f[B]<\f[R]
563 \f[B]>\f[R]
572 \f[R]
575 \f[B]&&\f[R]
584 \f[R]
587 \f[B]||\f[R]
596 \f[R]
601 \f[B]++\f[R] \f[B]--\f[R]
603 : The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
605 They require a named expression (see the \f[I]Named Expressions\f[R]
612 \f[R]
615 \f[B]-\f[R]
617 : The \f[B]negation\f[R] operator returns \f[B]0\f[R] if a user attempts
618 to negate any expression with the value \f[B]0\f[R].
621 \f[B]!\f[R]
623 : The \f[B]boolean not\f[R] operator returns \f[B]1\f[R] if the
624 expression is \f[B]0\f[R], or \f[B]0\f[R] otherwise.
628 This is a **non-portable extension**.
629 \f[R]
632 \f[B]\[ha]\f[R]
634 : The \f[B]power\f[R] operator (not the \f[B]exclusive or\f[R] operator,
637 The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
642 negative, the first value must be non-zero.
643 \f[R]
646 \f[B]*\f[R]
648 : The \f[B]multiply\f[R] operator takes two expressions, multiplies
650 If \f[B]a\f[R] is the \f[I]scale\f[R] of the first expression and
651 \f[B]b\f[R] is the \f[I]scale\f[R] of the second expression, the
652 \f[I]scale\f[R] of the result is equal to
653 \f[B]min(a+b,max(scale,a,b))\f[R] where \f[B]min()\f[R] and
654 \f[B]max()\f[R] return the obvious values.
656 \f[B]/\f[R]
658 : The \f[B]divide\f[R] operator takes two expressions, divides them, and
660 The \f[I]scale\f[R] of the result shall be the value of \f[B]scale\f[R].
664 The second expression must be non-zero.
665 \f[R]
668 \f[B]%\f[R]
670 : The \f[B]modulus\f[R] operator takes two expressions, \f[B]a\f[R] and
671 \f[B]b\f[R], and evaluates them by 1) Computing \f[B]a/b\f[R] to current
672 \f[B]scale\f[R] and 2) Using the result of step 1 to calculate
673 \f[B]a-(a/b)*b\f[R] to \f[I]scale\f[R]
674 \f[B]max(scale+scale(b),scale(a))\f[R].
678 The second expression must be non-zero.
679 \f[R]
682 \f[B]+\f[R]
684 : The \f[B]add\f[R] operator takes two expressions, \f[B]a\f[R] and
685 \f[B]b\f[R], and returns the sum, with a \f[I]scale\f[R] equal to the
686 max of the \f[I]scale\f[R]s of \f[B]a\f[R] and \f[B]b\f[R].
688 \f[B]-\f[R]
690 : The \f[B]subtract\f[R] operator takes two expressions, \f[B]a\f[R] and
691 \f[B]b\f[R], and returns the difference, with a \f[I]scale\f[R] equal to
692 the max of the \f[I]scale\f[R]s of \f[B]a\f[R] and \f[B]b\f[R].
694 \f[B]=\f[R] \f[B]+=\f[R] \f[B]-=\f[R] \f[B]*=\f[R] \f[B]/=\f[R]
695 \f[B]%=\f[R] \f[B]\[ha]=\f[R]
697 : The \f[B]assignment\f[R] operators take two expressions, \f[B]a\f[R]
698 and \f[B]b\f[R] where \f[B]a\f[R] is a named expression (see the
699 \f[I]Named Expressions\f[R] subsection).
706 \f[R]
709 \f[B]==\f[R] \f[B]<=\f[R] \f[B]>=\f[R] \f[B]!=\f[R] \f[B]<\f[R]
710 \f[B]>\f[R]
712 : The \f[B]relational\f[R] operators compare two expressions,
713 \f[B]a\f[R] and \f[B]b\f[R], and if the relation holds, according to C
714 language semantics, the result is \f[B]1\f[R].
715 Otherwise, it is \f[B]0\f[R].
725 **non-portable extension**.
726 \f[R]
729 \f[B]&&\f[R]
731 : The \f[B]boolean and\f[R] operator takes two expressions and returns
732 \f[B]1\f[R] if both expressions are non-zero, \f[B]0\f[R] otherwise.
736 This is *not* a short-circuit operator.
738 This is a **non-portable extension**.
739 \f[R]
742 \f[B]||\f[R]
744 : The \f[B]boolean or\f[R] operator takes two expressions and returns
745 \f[B]1\f[R] if one of the expressions is non-zero, \f[B]0\f[R]
750 This is *not* a short-circuit operator.
752 This is a **non-portable extension**.
753 \f[R]
759 \f[B]E\f[R]
761 \f[B]{\f[R] \f[B]S\f[R] \f[B];\f[R] ...
762 \f[B];\f[R] \f[B]S\f[R] \f[B]}\f[R]
764 \f[B]if\f[R] \f[B](\f[R] \f[B]E\f[R] \f[B])\f[R] \f[B]S\f[R]
766 \f[B]if\f[R] \f[B](\f[R] \f[B]E\f[R] \f[B])\f[R] \f[B]S\f[R]
767 \f[B]else\f[R] \f[B]S\f[R]
769 \f[B]while\f[R] \f[B](\f[R] \f[B]E\f[R] \f[B])\f[R] \f[B]S\f[R]
771 \f[B]for\f[R] \f[B](\f[R] \f[B]E\f[R] \f[B];\f[R] \f[B]E\f[R]
772 \f[B];\f[R] \f[B]E\f[R] \f[B])\f[R] \f[B]S\f[R]
776 \f[B]break\f[R]
778 \f[B]continue\f[R]
780 \f[B]quit\f[R]
782 \f[B]halt\f[R]
784 \f[B]limits\f[R]
788 \f[B]print\f[R] \f[B]E\f[R] \f[B],\f[R] ...
789 \f[B],\f[R] \f[B]E\f[R]
791 \f[B]I()\f[R], \f[B]I(E)\f[R], \f[B]I(E, E)\f[R], and so on, where
792 \f[B]I\f[R] is an identifier for a \f[B]void\f[R] function (see the
793 \f[I]Void Functions\f[R] subsection of the \f[B]FUNCTIONS\f[R] section).
794 The \f[B]E\f[R] argument(s) may also be arrays of the form
795 \f[B]I[]\f[R], which will automatically be turned into array references
796 (see the \f[I]Array References\f[R] subsection of the
797 \f[B]FUNCTIONS\f[R] section) if the corresponding parameter in the
800 Numbers 4, 9, 11, 12, 14, and 15 are \f[B]non-portable extensions\f[R].
802 Also, as a \f[B]non-portable extension\f[R], any or all of the
805 constant \f[B]1\f[R].
807 The \f[B]break\f[R] statement causes a loop to stop iterating and resume
811 The \f[B]continue\f[R] statement causes a loop iteration to stop early
816 The \f[B]if\f[R] \f[B]else\f[R] statement does the same thing as in C.
818 The \f[B]quit\f[R] statement causes bc(1) to quit, even if it is on a
819 branch that will not be executed (it is a compile-time command).
821 The \f[B]halt\f[R] statement causes bc(1) to quit, if it is executed.
822 (Unlike \f[B]quit\f[R] if it is on a branch of an \f[B]if\f[R] statement
825 The \f[B]limits\f[R] statement prints the limits that this bc(1) is
827 This is like the \f[B]quit\f[R] statement in that it is a compile-time
833 The \[dq]expressions\[dq] in a \f[B]print\f[R] statement may also be
842 \f[B]\[rs]a\f[R] \f[B]\[rs]a\f[R] \f[B]\[rs]b\f[R] \f[B]\[rs]b\f[R]
843 \f[B]\[rs]\[rs]\f[R] \f[B]\[rs]\f[R] \f[B]\[rs]e\f[R] \f[B]\[rs]\f[R]
844 \f[B]\[rs]f\f[R] \f[B]\[rs]f\f[R] \f[B]\[rs]n\f[R] \f[B]\[rs]n\f[R]
845 \f[B]\[rs]q\f[R] \f[B]\[dq]\f[R] \f[B]\[rs]r\f[R] \f[B]\[rs]r\f[R]
846 \f[B]\[rs]t\f[R] \f[B]\[rs]t\f[R]
851 character to be printed as-is.
853 Any non-string expression in a print statement shall be assigned to
854 \f[B]last\f[R], like any other expression that is printed.
859 This means, for example, assuming that \f[B]i\f[R] is equal to
860 \f[B]0\f[R], in the expression
865 \f[R]
868 the first (or 0th) element of \f[B]a\f[R] is set to \f[B]1\f[R], and
869 \f[B]i\f[R] is equal to \f[B]2\f[R] at the end of the expression.
872 Thus, assuming \f[B]i\f[R] is equal to \f[B]0\f[R], this means that in
878 \f[R]
881 the first argument passed to \f[B]x()\f[R] is \f[B]0\f[R], and the
882 second argument is \f[B]1\f[R], while \f[B]i\f[R] is equal to
883 \f[B]2\f[R] before the function starts executing.
895 \f[R]
898 Any \f[B]I\f[R] in the parameter list or \f[B]auto\f[R] list may be
899 replaced with \f[B]I[]\f[R] to make a parameter or \f[B]auto\f[R] var an
900 array, and any \f[B]I\f[R] in the parameter list may be replaced with
901 \f[B]*I[]\f[R] to make a parameter an array reference.
903 asterisk in the call; they must be called with just \f[B]I[]\f[R] like
907 As a \f[B]non-portable extension\f[R], the opening brace of a
908 \f[B]define\f[R] statement may appear on the next line.
910 As a \f[B]non-portable extension\f[R], the return statement may also be
913 \f[B]return\f[R]
915 \f[B]return\f[R] \f[B](\f[R] \f[B])\f[R]
917 \f[B]return\f[R] \f[B]E\f[R]
919 The first two, or not specifying a \f[B]return\f[R] statement, is
920 equivalent to \f[B]return (0)\f[R], unless the function is a
921 \f[B]void\f[R] function (see the \f[I]Void Functions\f[R] subsection
925 Functions can also be \f[B]void\f[R] functions, defined as follows:
934 \f[R]
940 Void functions can only use the first two \f[B]return\f[R] statements
945 possible to have variables, arrays, and functions named \f[B]void\f[R].
947 \f[B]define\f[R] keyword.
949 This is a \f[B]non-portable extension\f[R].
958 \f[R]
961 it is a \f[B]reference\f[R].
967 This is a \f[B]non-portable extension\f[R].
970 All of the functions below are available when the \f[B]-l\f[R] or
971 \f[B]--mathlib\f[R] command-line flags are given.
978 \f[B]s(x)\f[R]
980 : Returns the sine of \f[B]x\f[R], which is assumed to be in radians.
986 \f[R]
989 \f[B]c(x)\f[R]
991 : Returns the cosine of \f[B]x\f[R], which is assumed to be in radians.
997 \f[R]
1000 \f[B]a(x)\f[R]
1002 : Returns the arctangent of \f[B]x\f[R], in radians.
1008 \f[R]
1011 \f[B]l(x)\f[R]
1013 : Returns the natural logarithm of \f[B]x\f[R].
1019 \f[R]
1022 \f[B]e(x)\f[R]
1024 : Returns the mathematical constant \f[B]e\f[R] raised to the power of
1025 \f[B]x\f[R].
1031 \f[R]
1034 \f[B]j(x, n)\f[R]
1036 : Returns the bessel integer order \f[B]n\f[R] (truncated) of
1037 \f[B]x\f[R].
1043 \f[R]
1055 functions with the precision (\f[B]scale\f[R]) set to at least 1 higher
1057 If exact results are \f[I]absolutely\f[R] required, users can double the
1058 precision (\f[B]scale\f[R]) and then truncate.
1062 \f[B]s(x)\f[R]
1064 \f[B]c(x)\f[R]
1066 \f[B]a(x)\f[R]
1068 \f[B]l(x)\f[R]
1070 \f[B]e(x)\f[R]
1072 \f[B]j(x, n)\f[R]
1075 When bc(1) encounters an error or a signal that it has a non-default
1088 (see the \f[B]EXIT STATUS\f[R] section), it asks for more input;
1096 Most bc(1) implementations use \f[B]char\f[R] types to calculate the
1097 value of \f[B]1\f[R] decimal digit at a time, but that can be slow.
1100 It uses large integers to calculate more than \f[B]1\f[R] decimal digit
1102 If built in a environment where \f[B]BC_LONG_BIT\f[R] (see the
1103 \f[B]LIMITS\f[R] section) is \f[B]64\f[R], then each integer has
1104 \f[B]9\f[R] decimal digits.
1105 If built in an environment where \f[B]BC_LONG_BIT\f[R] is \f[B]32\f[R]
1106 then each integer has \f[B]4\f[R] decimal digits.
1108 \f[B]BC_BASE_DIGS\f[R].
1110 The actual values of \f[B]BC_LONG_BIT\f[R] and \f[B]BC_BASE_DIGS\f[R]
1111 can be queried with the \f[B]limits\f[R] statement.
1115 This integer type depends on the value of \f[B]BC_LONG_BIT\f[R], but is
1121 \f[B]BC_LONG_BIT\f[R]
1123 : The number of bits in the \f[B]long\f[R] type in the environment where
1126 integer (see the \f[B]PERFORMANCE\f[R] section).
1128 \f[B]BC_BASE_DIGS\f[R]
1131 \f[B]PERFORMANCE\f[R] section).
1132 Depends on \f[B]BC_LONG_BIT\f[R].
1134 \f[B]BC_BASE_POW\f[R]
1137 \f[B]BC_BASE_DIGS\f[R]) plus \f[B]1\f[R].
1138 Depends on \f[B]BC_BASE_DIGS\f[R].
1140 \f[B]BC_OVERFLOW_MAX\f[R]
1142 : The max number that the overflow type (see the \f[B]PERFORMANCE\f[R]
1144 Depends on \f[B]BC_LONG_BIT\f[R].
1146 \f[B]BC_BASE_MAX\f[R]
1149 Set at \f[B]BC_BASE_POW\f[R].
1151 \f[B]BC_DIM_MAX\f[R]
1154 Set at \f[B]SIZE_MAX-1\f[R].
1156 \f[B]BC_SCALE_MAX\f[R]
1158 : The maximum \f[B]scale\f[R].
1159 Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
1161 \f[B]BC_STRING_MAX\f[R]
1164 Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
1166 \f[B]BC_NAME_MAX\f[R]
1169 Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
1171 \f[B]BC_NUM_MAX\f[R]
1175 Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
1180 Set at \f[B]BC_OVERFLOW_MAX\f[R].
1185 Set at \f[B]SIZE_MAX-1\f[R].
1187 The actual values can be queried with the \f[B]limits\f[R] statement.
1189 These limits are meant to be effectively non-existent; the limits are so
1190 large (at least on 64-bit machines) that there should not be any point
1197 \f[B]POSIXLY_CORRECT\f[R]
1200 the \f[B]-s\f[R] option was given.
1202 \f[B]BC_ENV_ARGS\f[R]
1204 : This is another way to give command-line arguments to bc(1).
1205 They should be in the same format as all other command-line arguments.
1207 \f[B]BC_ENV_ARGS\f[R] will be processed before arguments and files given
1208 on the command-line.
1227 command-line where the parsing is done by the shell.
1228 \f[R]
1231 \f[B]BC_LINE_LENGTH\f[R]
1234 greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
1235 (\f[B]2\[ha]16-1\f[R]), bc(1) will output lines to that length,
1236 including the backslash (\f[B]\[rs]\f[R]).
1237 The default line length is \f[B]70\f[R].
1242 \f[B]0\f[R]
1246 \f[B]1\f[R]
1249 This follows standard practice of using \f[B]1\f[R] for expected errors,
1257 use a non-integer where an integer is required.
1261 \f[R]
1264 \f[B]2\f[R]
1278 variable as a reference, and using any extensions when the option **-s** or
1280 \f[R]
1283 \f[B]3\f[R]
1294 \f[R]
1297 \f[B]4\f[R]
1306 and giving invalid command-line options.
1307 \f[R]
1310 The exit status \f[B]4\f[R] is special; when a fatal error occurs, bc(1)
1311 always exits and returns \f[B]4\f[R], no matter what mode bc(1) is in.
1314 interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
1315 bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
1318 \f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
1322 \f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
1327 bc(1) has an interactive mode and a non-interactive mode.
1328 Interactive mode is turned on automatically when both \f[B]stdin\f[R]
1329 and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
1330 and \f[B]--interactive\f[R] option can turn it on in other cases.
1333 \f[B]RESET\f[R] section), and in normal execution, flushes
1334 \f[B]stdout\f[R] as soon as execution is done for the current input.
1337 If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
1341 LINE HISTORY\f[R] section).
1342 It is also required to enable special handling for \f[B]SIGINT\f[R]
1350 and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
1354 Sending a \f[B]SIGINT\f[R] will cause bc(1) to stop execution of the
1356 If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
1357 reset (see the \f[B]RESET\f[R] section).
1361 If bc(1) is processing input from \f[B]stdin\f[R] in TTY mode, it will
1365 or ask for input from \f[B]stdin\f[R] if no other file exists.
1367 This means that if a \f[B]SIGINT\f[R] is sent to bc(1) as it is
1376 \f[B]SIGTERM\f[R] and \f[B]SIGQUIT\f[R] cause bc(1) to clean up and
1378 The one exception is \f[B]SIGHUP\f[R]; in that case, when bc(1) is in
1379 TTY mode, a \f[B]SIGHUP\f[R] will cause bc(1) to clean up and exit.
1382 bc(1) supports interactive command-line editing.
1383 If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), history is
1387 \f[B]Note\f[R]: tabs are converted to 8 spaces.
1393 bc(1) is compliant with the IEEE Std 1003.1-2017
1394 (\[lq]POSIX.1-2017\[rq]) (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
1396 The flags \f[B]-efghiqsvVw\f[R], all long options, and the extensions
1400 numbers that use a period (\f[B].\f[R]) as a radix point, regardless of
1401 the value of \f[B]LC_NUMERIC\f[R].