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
62 \f[B]-g\f[R], \f[B]--global-stacks\f[R]
64 : Turns the globals \f[B]ibase\f[R], \f[B]obase\f[R], \f[B]scale\f[R],
65 and \f[B]seed\f[R] into stacks.
105 alias d2o=\[dq]bc -e ibase=A -e obase=8\[dq]
106 alias h2b=\[dq]bc -e ibase=G -e obase=2\[dq]
115 pseudo-random numbers that they see will not be the same sequence of
116 pseudo-random numbers that any parent sees. This is only the case once
119 If a function desires to not affect the sequence of pseudo-random numbers
129 If **-s**, **-w**, or any equivalents are used, this option is ignored.
131 This is a **non-portable extension**.
132 \f[R]
135 \f[B]-h\f[R], \f[B]--help\f[R]
139 \f[B]-i\f[R], \f[B]--interactive\f[R]
142 (See the \f[B]INTERACTIVE MODE\f[R] section.)
146 This is a **non-portable extension**.
147 \f[R]
150 \f[B]-l\f[R], \f[B]--mathlib\f[R]
152 : Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to
153 \f[B]20\f[R] and loads the included math library and the extended math
160 \f[R]
163 \f[B]-P\f[R], \f[B]--no-prompt\f[R]
165 : This option is a no-op.
169 This is a **non-portable extension**.
170 \f[R]
173 \f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
176 no-op.
180 This is a **non-portable extension**.
181 \f[R]
184 \f[B]-q\f[R], \f[B]--quiet\f[R]
187 bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
190 \f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
194 This is a **non-portable extension**.
195 \f[R]
198 \f[B]-s\f[R], \f[B]--standard\f[R]
206 This is a **non-portable extension**.
207 \f[R]
210 \f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
216 This is a **non-portable extension**.
217 \f[R]
220 \f[B]-w\f[R], \f[B]--warn\f[R]
222 : Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
223 not errors) are printed for non-standard extensions and execution
228 This is a **non-portable extension**.
229 \f[R]
232 \f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
234 : Evaluates \f[I]expr\f[R].
243 If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
245 expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
246 as an argument at least once to **-f** or **-\[rs]-file**, whether on the
247 command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
248 **-\[rs]-expression**, **-f**, or **-\[rs]-file** arguments are given after **-f-**
251 This is a **non-portable extension**.
252 \f[R]
255 \f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
257 : Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
258 were read through \f[B]stdin\f[R].
264 If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
266 expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
267 as an argument at least once to **-f** or **-\[rs]-file**. However, if any other
268 **-e**, **-\[rs]-expression**, **-f**, or **-\[rs]-file** arguments are given after
269 **-f-** or equivalent is given, bc(1) will give a fatal error and exit.
271 This is a **non-portable extension**.
272 \f[R]
275 All long options are \f[B]non-portable extensions\f[R].
278 Any non-error output is written to \f[B]stdout\f[R].
279 In addition, if history (see the \f[B]HISTORY\f[R] section) and the
280 prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
281 to \f[B]stdout\f[R].
283 \f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
284 issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
285 write to \f[B]stdout\f[R], so if \f[B]stdout\f[R] is closed, as in
286 \f[B]bc >&-\f[R], it will quit with an error.
287 This is done so that bc(1) can report problems when \f[B]stdout\f[R] is
292 redirect \f[B]stdout\f[R] to \f[B]/dev/null\f[R].
295 Any error output is written to \f[B]stderr\f[R].
297 \f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
298 issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
299 write to \f[B]stderr\f[R], so if \f[B]stderr\f[R] is closed, as in
300 \f[B]bc 2>&-\f[R], it will quit with an error.
302 \f[B]stderr\f[R] is redirected to a file.
306 redirect \f[B]stderr\f[R] to \f[B]/dev/null\f[R].
309 The syntax for bc(1) programs is mostly C-like, with some differences.
317 In the sections below, \f[B]E\f[R] means expression, \f[B]S\f[R] means
318 statement, and \f[B]I\f[R] means identifier.
320 Identifiers (\f[B]I\f[R]) start with a lowercase letter and can be
321 followed by any number (up to \f[B]BC_NAME_MAX-1\f[R]) of lowercase
322 letters (\f[B]a-z\f[R]), digits (\f[B]0-9\f[R]), and underscores
323 (\f[B]_\f[R]).
324 The regex is \f[B][a-z][a-z0-9_]*\f[R].
326 \f[B]non-portable extension\f[R].
328 \f[B]ibase\f[R] is a global variable determining how to interpret
332 \f[B]ibase\f[R] is initially \f[B]10\f[R].
333 If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
334 (\f[B]--warn\f[R]) flags were not given on the command line, the max
335 allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
336 Otherwise, it is \f[B]16\f[R].
337 The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
338 The max allowable value for \f[B]ibase\f[R] can be queried in bc(1)
339 programs with the \f[B]maxibase()\f[R] built-in function.
341 \f[B]obase\f[R] is a global variable determining how to output results.
344 \f[B]obase\f[R] is initially \f[B]10\f[R].
345 The max allowable value for \f[B]obase\f[R] is \f[B]BC_BASE_MAX\f[R] and
346 can be queried in bc(1) programs with the \f[B]maxobase()\f[R] built-in
348 The min allowable value for \f[B]obase\f[R] is \f[B]0\f[R].
349 If \f[B]obase\f[R] is \f[B]0\f[R], values are output in scientific
350 notation, and if \f[B]obase\f[R] is \f[B]1\f[R], values are output in
354 Outputting in scientific and engineering notations are \f[B]non-portable
355 extensions\f[R].
357 The \f[I]scale\f[R] of an expression is the number of digits in the
358 result of the expression right of the decimal point, and \f[B]scale\f[R]
361 \f[B]scale\f[R] is initially \f[B]0\f[R].
362 \f[B]scale\f[R] cannot be negative.
363 The max allowable value for \f[B]scale\f[R] is \f[B]BC_SCALE_MAX\f[R]
364 and can be queried in bc(1) programs with the \f[B]maxscale()\f[R]
365 built-in function.
367 bc(1) has both \f[I]global\f[R] variables and \f[I]local\f[R] variables.
368 All \f[I]local\f[R] variables are local to the function; they are
369 parameters or are introduced in the \f[B]auto\f[R] list of a function
370 (see the \f[B]FUNCTIONS\f[R] section).
372 \f[B]auto\f[R] list, it is assumed to be \f[I]global\f[R].
373 If a parent function has a \f[I]local\f[R] variable version of a
374 variable that a child function considers \f[I]global\f[R], the value of
375 that \f[I]global\f[R] variable in the child function is the value of the
377 \f[I]global\f[R] variable.
383 operator is an assignment operator \f[I]and\f[R] the expression is
387 \f[B]last\f[R].
388 A single dot (\f[B].\f[R]) may also be used as a synonym for
389 \f[B]last\f[R].
390 These are \f[B]non-portable extensions\f[R].
397 Block comments are enclosed in \f[B]/*\f[R] and \f[B]*/\f[R].
399 Line comments go from \f[B]#\f[R] until, and not including, the next
401 This is a \f[B]non-portable extension\f[R].
406 Variables: \f[B]I\f[R]
408 Array Elements: \f[B]I[E]\f[R]
410 \f[B]ibase\f[R]
412 \f[B]obase\f[R]
414 \f[B]scale\f[R]
416 \f[B]seed\f[R]
418 \f[B]last\f[R] or a single dot (\f[B].\f[R])
420 Numbers 6 and 7 are \f[B]non-portable extensions\f[R].
422 The meaning of \f[B]seed\f[R] is dependent on the current pseudo-random
426 The \f[I]scale\f[R] and sign of the value may be significant.
428 If a previously used \f[B]seed\f[R] value is assigned to \f[B]seed\f[R]
429 and used again, the pseudo-random number generator is guaranteed to
430 produce the same sequence of pseudo-random numbers as it did when the
431 \f[B]seed\f[R] value was previously used.
433 The exact value assigned to \f[B]seed\f[R] is not guaranteed to be
434 returned if \f[B]seed\f[R] is queried again immediately.
435 However, if \f[B]seed\f[R] \f[I]does\f[R] return a different value, both
436 values, when assigned to \f[B]seed\f[R], are guaranteed to produce the
437 same sequence of pseudo-random numbers.
438 This means that certain values assigned to \f[B]seed\f[R] will
439 \f[I]not\f[R] produce unique sequences of pseudo-random numbers.
440 The value of \f[B]seed\f[R] will change after any use of the
441 \f[B]rand()\f[R] and \f[B]irand(E)\f[R] operands (see the
442 \f[I]Operands\f[R] subsection below), except if the parameter passed to
443 \f[B]irand(E)\f[R] is \f[B]0\f[R], \f[B]1\f[R], or negative.
446 or \f[I]scale\f[R] of the value that can be assigned to \f[B]seed\f[R].
450 This also applies to functions (see the \f[B]FUNCTIONS\f[R] section), so
456 \f[B]increment\f[R]/\f[B]decrement\f[R] operators and as the left side
457 of \f[B]assignment\f[R] operators (see the \f[I]Operators\f[R]
463 Numbers (see the \f[I]Numbers\f[R] subsection below).
465 Array indices (\f[B]I[E]\f[R]).
467 \f[B](E)\f[R]: The value of \f[B]E\f[R] (used to change precedence).
469 \f[B]sqrt(E)\f[R]: The square root of \f[B]E\f[R].
470 \f[B]E\f[R] must be non-negative.
472 \f[B]length(E)\f[R]: The number of significant decimal digits in
473 \f[B]E\f[R].
475 \f[B]length(I[])\f[R]: The number of elements in the array \f[B]I\f[R].
476 This is a \f[B]non-portable extension\f[R].
478 \f[B]scale(E)\f[R]: The \f[I]scale\f[R] of \f[B]E\f[R].
480 \f[B]abs(E)\f[R]: The absolute value of \f[B]E\f[R].
481 This is a \f[B]non-portable extension\f[R].
483 \f[B]I()\f[R], \f[B]I(E)\f[R], \f[B]I(E, E)\f[R], and so on, where
484 \f[B]I\f[R] is an identifier for a non-\f[B]void\f[R] function (see the
485 \f[I]Void Functions\f[R] subsection of the \f[B]FUNCTIONS\f[R] section).
486 The \f[B]E\f[R] argument(s) may also be arrays of the form
487 \f[B]I[]\f[R], which will automatically be turned into array references
488 (see the \f[I]Array References\f[R] subsection of the
489 \f[B]FUNCTIONS\f[R] section) if the corresponding parameter in the
492 \f[B]read()\f[R]: Reads a line from \f[B]stdin\f[R] and uses that as an
494 The result of that expression is the result of the \f[B]read()\f[R]
496 This is a \f[B]non-portable extension\f[R].
498 \f[B]maxibase()\f[R]: The max allowable \f[B]ibase\f[R].
499 This is a \f[B]non-portable extension\f[R].
501 \f[B]maxobase()\f[R]: The max allowable \f[B]obase\f[R].
502 This is a \f[B]non-portable extension\f[R].
504 \f[B]maxscale()\f[R]: The max allowable \f[B]scale\f[R].
505 This is a \f[B]non-portable extension\f[R].
507 \f[B]rand()\f[R]: A pseudo-random integer between \f[B]0\f[R]
508 (inclusive) and \f[B]BC_RAND_MAX\f[R] (inclusive).
509 Using this operand will change the value of \f[B]seed\f[R].
510 This is a \f[B]non-portable extension\f[R].
512 \f[B]irand(E)\f[R]: A pseudo-random integer between \f[B]0\f[R]
513 (inclusive) and the value of \f[B]E\f[R] (exclusive).
514 If \f[B]E\f[R] is negative or is a non-integer (\f[B]E\f[R]\[aq]s
515 \f[I]scale\f[R] is not \f[B]0\f[R]), an error is raised, and bc(1)
516 resets (see the \f[B]RESET\f[R] section) while \f[B]seed\f[R] remains
518 If \f[B]E\f[R] is larger than \f[B]BC_RAND_MAX\f[R], the higher bound is
519 honored by generating several pseudo-random integers, multiplying them
520 by appropriate powers of \f[B]BC_RAND_MAX+1\f[R], and adding them
524 Using this operand will change the value of \f[B]seed\f[R], unless the
525 value of \f[B]E\f[R] is \f[B]0\f[R] or \f[B]1\f[R].
526 In that case, \f[B]0\f[R] is returned, and \f[B]seed\f[R] is
527 \f[I]not\f[R] changed.
528 This is a \f[B]non-portable extension\f[R].
530 \f[B]maxrand()\f[R]: The max integer returned by \f[B]rand()\f[R].
531 This is a \f[B]non-portable extension\f[R].
533 The integers generated by \f[B]rand()\f[R] and \f[B]irand(E)\f[R] are
535 the pseudo-random number generator.
537 \f[B]Note\f[R]: The values returned by the pseudo-random number
538 generator with \f[B]rand()\f[R] and \f[B]irand(E)\f[R] are guaranteed to
539 \f[I]NOT\f[R] be cryptographically secure.
540 This is a consequence of using a seeded pseudo-random number generator.
541 However, they \f[I]are\f[R] guaranteed to be reproducible with identical
542 \f[B]seed\f[R] values.
543 This means that the pseudo-random values from bc(1) should only be used
544 where a reproducible stream of pseudo-random numbers is
545 \f[I]ESSENTIAL\f[R].
546 In any other case, use a non-seeded pseudo-random number generator.
550 \f[B]1\f[R] period for a radix.
551 Numbers can have up to \f[B]BC_NUM_MAX\f[R] digits.
552 Uppercase letters are equal to \f[B]9\f[R] + their position in the
553 alphabet (i.e., \f[B]A\f[R] equals \f[B]10\f[R], or \f[B]9+1\f[R]).
555 \f[B]ibase\f[R], they are set to the value of the highest valid digit in
556 \f[B]ibase\f[R].
558 Single-character numbers (i.e., \f[B]A\f[R] alone) take the value that
560 \f[B]ibase\f[R].
561 This means that \f[B]A\f[R] alone always equals decimal \f[B]10\f[R] and
562 \f[B]Z\f[R] alone always equals decimal \f[B]35\f[R].
565 These have the form \f[B]<number>e<integer>\f[R].
566 The exponent (the portion after the \f[B]e\f[R]) must be an integer.
567 An example is \f[B]1.89237e9\f[R], which is equal to
568 \f[B]1892370000\f[R].
569 Negative exponents are also allowed, so \f[B]4.2890e-3\f[R] is equal to
570 \f[B]0.0042890\f[R].
572 Using scientific notation is an error or warning if the \f[B]-s\f[R] or
573 \f[B]-w\f[R], respectively, command-line options (or equivalents) are
576 \f[B]WARNING\f[R]: Both the number and the exponent in scientific
577 notation are interpreted according to the current \f[B]ibase\f[R], but
578 the number is still multiplied by \f[B]10\[ha]exponent\f[R] regardless
579 of the current \f[B]ibase\f[R].
580 For example, if \f[B]ibase\f[R] is \f[B]16\f[R] and bc(1) is given the
581 number string \f[B]FFeA\f[R], the resulting decimal number will be
582 \f[B]2550000000000\f[R], and if bc(1) is given the number string
583 \f[B]10e-4\f[R], the resulting decimal number will be \f[B]0.0016\f[R].
585 Accepting input as scientific notation is a \f[B]non-portable
586 extension\f[R].
593 \f[B]++\f[R] \f[B]--\f[R]
602 \f[R]
605 \f[B]-\f[R] \f[B]!\f[R]
614 \f[R]
617 \f[B]$\f[R]
626 \f[R]
629 \f[B]\[at]\f[R]
638 \f[R]
641 \f[B]\[ha]\f[R]
650 \f[R]
653 \f[B]*\f[R] \f[B]/\f[R] \f[B]%\f[R]
662 \f[R]
665 \f[B]+\f[R] \f[B]-\f[R]
674 \f[R]
677 \f[B]<<\f[R] \f[B]>>\f[R]
686 \f[R]
689 \f[B]=\f[R] \f[B]<<=\f[R] \f[B]>>=\f[R] \f[B]+=\f[R] \f[B]-=\f[R]
690 \f[B]*=\f[R] \f[B]/=\f[R] \f[B]%=\f[R] \f[B]\[ha]=\f[R] \f[B]\[at]=\f[R]
699 \f[R]
702 \f[B]==\f[R] \f[B]<=\f[R] \f[B]>=\f[R] \f[B]!=\f[R] \f[B]<\f[R]
703 \f[B]>\f[R]
712 \f[R]
715 \f[B]&&\f[R]
724 \f[R]
727 \f[B]||\f[R]
736 \f[R]
741 \f[B]++\f[R] \f[B]--\f[R]
743 : The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
745 They require a named expression (see the \f[I]Named Expressions\f[R]
752 \f[R]
755 \f[B]-\f[R]
757 : The \f[B]negation\f[R] operator returns \f[B]0\f[R] if a user attempts
758 to negate any expression with the value \f[B]0\f[R].
761 \f[B]!\f[R]
763 : The \f[B]boolean not\f[R] operator returns \f[B]1\f[R] if the
764 expression is \f[B]0\f[R], or \f[B]0\f[R] otherwise.
768 This is a **non-portable extension**.
769 \f[R]
772 \f[B]$\f[R]
774 : The \f[B]truncation\f[R] operator returns a copy of the given
775 expression with all of its \f[I]scale\f[R] removed.
779 This is a **non-portable extension**.
780 \f[R]
783 \f[B]\[at]\f[R]
785 : The \f[B]set precision\f[R] operator takes two expressions and returns
786 a copy of the first with its \f[I]scale\f[R] equal to the value of the
789 the \f[I]scale\f[R] of the first expression matches the value of the
795 The second expression must be an integer (no *scale*) and non-negative.
797 This is a **non-portable extension**.
798 \f[R]
801 \f[B]\[ha]\f[R]
803 : The \f[B]power\f[R] operator (not the \f[B]exclusive or\f[R] operator,
806 The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
811 negative, the first value must be non-zero.
812 \f[R]
815 \f[B]*\f[R]
817 : The \f[B]multiply\f[R] operator takes two expressions, multiplies
819 If \f[B]a\f[R] is the \f[I]scale\f[R] of the first expression and
820 \f[B]b\f[R] is the \f[I]scale\f[R] of the second expression, the
821 \f[I]scale\f[R] of the result is equal to
822 \f[B]min(a+b,max(scale,a,b))\f[R] where \f[B]min()\f[R] and
823 \f[B]max()\f[R] return the obvious values.
825 \f[B]/\f[R]
827 : The \f[B]divide\f[R] operator takes two expressions, divides them, and
829 The \f[I]scale\f[R] of the result shall be the value of \f[B]scale\f[R].
833 The second expression must be non-zero.
834 \f[R]
837 \f[B]%\f[R]
839 : The \f[B]modulus\f[R] operator takes two expressions, \f[B]a\f[R] and
840 \f[B]b\f[R], and evaluates them by 1) Computing \f[B]a/b\f[R] to current
841 \f[B]scale\f[R] and 2) Using the result of step 1 to calculate
842 \f[B]a-(a/b)*b\f[R] to \f[I]scale\f[R]
843 \f[B]max(scale+scale(b),scale(a))\f[R].
847 The second expression must be non-zero.
848 \f[R]
851 \f[B]+\f[R]
853 : The \f[B]add\f[R] operator takes two expressions, \f[B]a\f[R] and
854 \f[B]b\f[R], and returns the sum, with a \f[I]scale\f[R] equal to the
855 max of the \f[I]scale\f[R]s of \f[B]a\f[R] and \f[B]b\f[R].
857 \f[B]-\f[R]
859 : The \f[B]subtract\f[R] operator takes two expressions, \f[B]a\f[R] and
860 \f[B]b\f[R], and returns the difference, with a \f[I]scale\f[R] equal to
861 the max of the \f[I]scale\f[R]s of \f[B]a\f[R] and \f[B]b\f[R].
863 \f[B]<<\f[R]
865 : The \f[B]left shift\f[R] operator takes two expressions, \f[B]a\f[R]
866 and \f[B]b\f[R], and returns a copy of the value of \f[B]a\f[R] with its
867 decimal point moved \f[B]b\f[R] places to the right.
871 The second expression must be an integer (no *scale*) and non-negative.
873 This is a **non-portable extension**.
874 \f[R]
877 \f[B]>>\f[R]
879 : The \f[B]right shift\f[R] operator takes two expressions, \f[B]a\f[R]
880 and \f[B]b\f[R], and returns a copy of the value of \f[B]a\f[R] with its
881 decimal point moved \f[B]b\f[R] places to the left.
885 The second expression must be an integer (no *scale*) and non-negative.
887 This is a **non-portable extension**.
888 \f[R]
891 \f[B]=\f[R] \f[B]<<=\f[R] \f[B]>>=\f[R] \f[B]+=\f[R] \f[B]-=\f[R]
892 \f[B]*=\f[R] \f[B]/=\f[R] \f[B]%=\f[R] \f[B]\[ha]=\f[R] \f[B]\[at]=\f[R]
894 : The \f[B]assignment\f[R] operators take two expressions, \f[B]a\f[R]
895 and \f[B]b\f[R] where \f[B]a\f[R] is a named expression (see the
896 \f[I]Named Expressions\f[R] subsection).
905 extensions are themselves **non-portable extensions**.
906 \f[R]
909 \f[B]==\f[R] \f[B]<=\f[R] \f[B]>=\f[R] \f[B]!=\f[R] \f[B]<\f[R]
910 \f[B]>\f[R]
912 : The \f[B]relational\f[R] operators compare two expressions,
913 \f[B]a\f[R] and \f[B]b\f[R], and if the relation holds, according to C
914 language semantics, the result is \f[B]1\f[R].
915 Otherwise, it is \f[B]0\f[R].
925 **non-portable extension**.
926 \f[R]
929 \f[B]&&\f[R]
931 : The \f[B]boolean and\f[R] operator takes two expressions and returns
932 \f[B]1\f[R] if both expressions are non-zero, \f[B]0\f[R] otherwise.
936 This is *not* a short-circuit operator.
938 This is a **non-portable extension**.
939 \f[R]
942 \f[B]||\f[R]
944 : The \f[B]boolean or\f[R] operator takes two expressions and returns
945 \f[B]1\f[R] if one of the expressions is non-zero, \f[B]0\f[R]
950 This is *not* a short-circuit operator.
952 This is a **non-portable extension**.
953 \f[R]
959 \f[B]E\f[R]
961 \f[B]{\f[R] \f[B]S\f[R] \f[B];\f[R] ...
962 \f[B];\f[R] \f[B]S\f[R] \f[B]}\f[R]
964 \f[B]if\f[R] \f[B](\f[R] \f[B]E\f[R] \f[B])\f[R] \f[B]S\f[R]
966 \f[B]if\f[R] \f[B](\f[R] \f[B]E\f[R] \f[B])\f[R] \f[B]S\f[R]
967 \f[B]else\f[R] \f[B]S\f[R]
969 \f[B]while\f[R] \f[B](\f[R] \f[B]E\f[R] \f[B])\f[R] \f[B]S\f[R]
971 \f[B]for\f[R] \f[B](\f[R] \f[B]E\f[R] \f[B];\f[R] \f[B]E\f[R]
972 \f[B];\f[R] \f[B]E\f[R] \f[B])\f[R] \f[B]S\f[R]
976 \f[B]break\f[R]
978 \f[B]continue\f[R]
980 \f[B]quit\f[R]
982 \f[B]halt\f[R]
984 \f[B]limits\f[R]
988 \f[B]print\f[R] \f[B]E\f[R] \f[B],\f[R] ...
989 \f[B],\f[R] \f[B]E\f[R]
991 \f[B]I()\f[R], \f[B]I(E)\f[R], \f[B]I(E, E)\f[R], and so on, where
992 \f[B]I\f[R] is an identifier for a \f[B]void\f[R] function (see the
993 \f[I]Void Functions\f[R] subsection of the \f[B]FUNCTIONS\f[R] section).
994 The \f[B]E\f[R] argument(s) may also be arrays of the form
995 \f[B]I[]\f[R], which will automatically be turned into array references
996 (see the \f[I]Array References\f[R] subsection of the
997 \f[B]FUNCTIONS\f[R] section) if the corresponding parameter in the
1000 Numbers 4, 9, 11, 12, 14, and 15 are \f[B]non-portable extensions\f[R].
1002 Also, as a \f[B]non-portable extension\f[R], any or all of the
1005 constant \f[B]1\f[R].
1007 The \f[B]break\f[R] statement causes a loop to stop iterating and resume
1011 The \f[B]continue\f[R] statement causes a loop iteration to stop early
1016 The \f[B]if\f[R] \f[B]else\f[R] statement does the same thing as in C.
1018 The \f[B]quit\f[R] statement causes bc(1) to quit, even if it is on a
1019 branch that will not be executed (it is a compile-time command).
1021 The \f[B]halt\f[R] statement causes bc(1) to quit, if it is executed.
1022 (Unlike \f[B]quit\f[R] if it is on a branch of an \f[B]if\f[R] statement
1025 The \f[B]limits\f[R] statement prints the limits that this bc(1) is
1027 This is like the \f[B]quit\f[R] statement in that it is a compile-time
1034 Scientific notation is activated by assigning \f[B]0\f[R] to
1035 \f[B]obase\f[R], and engineering notation is activated by assigning
1036 \f[B]1\f[R] to \f[B]obase\f[R].
1037 To deactivate them, just assign a different value to \f[B]obase\f[R].
1040 run with either the \f[B]-s\f[R] or \f[B]-w\f[R] command-line options
1044 \f[B]non-portable extension\f[R].
1047 The \[dq]expressions\[dq] in a \f[B]print\f[R] statement may also be
1056 \f[B]\[rs]a\f[R] \f[B]\[rs]a\f[R] \f[B]\[rs]b\f[R] \f[B]\[rs]b\f[R]
1057 \f[B]\[rs]\[rs]\f[R] \f[B]\[rs]\f[R] \f[B]\[rs]e\f[R] \f[B]\[rs]\f[R]
1058 \f[B]\[rs]f\f[R] \f[B]\[rs]f\f[R] \f[B]\[rs]n\f[R] \f[B]\[rs]n\f[R]
1059 \f[B]\[rs]q\f[R] \f[B]\[dq]\f[R] \f[B]\[rs]r\f[R] \f[B]\[rs]r\f[R]
1060 \f[B]\[rs]t\f[R] \f[B]\[rs]t\f[R]
1065 character to be printed as-is.
1067 Any non-string expression in a print statement shall be assigned to
1068 \f[B]last\f[R], like any other expression that is printed.
1073 This means, for example, assuming that \f[B]i\f[R] is equal to
1074 \f[B]0\f[R], in the expression
1079 \f[R]
1082 the first (or 0th) element of \f[B]a\f[R] is set to \f[B]1\f[R], and
1083 \f[B]i\f[R] is equal to \f[B]2\f[R] at the end of the expression.
1086 Thus, assuming \f[B]i\f[R] is equal to \f[B]0\f[R], this means that in
1092 \f[R]
1095 the first argument passed to \f[B]x()\f[R] is \f[B]0\f[R], and the
1096 second argument is \f[B]1\f[R], while \f[B]i\f[R] is equal to
1097 \f[B]2\f[R] before the function starts executing.
1109 \f[R]
1112 Any \f[B]I\f[R] in the parameter list or \f[B]auto\f[R] list may be
1113 replaced with \f[B]I[]\f[R] to make a parameter or \f[B]auto\f[R] var an
1114 array, and any \f[B]I\f[R] in the parameter list may be replaced with
1115 \f[B]*I[]\f[R] to make a parameter an array reference.
1117 asterisk in the call; they must be called with just \f[B]I[]\f[R] like
1121 As a \f[B]non-portable extension\f[R], the opening brace of a
1122 \f[B]define\f[R] statement may appear on the next line.
1124 As a \f[B]non-portable extension\f[R], the return statement may also be
1127 \f[B]return\f[R]
1129 \f[B]return\f[R] \f[B](\f[R] \f[B])\f[R]
1131 \f[B]return\f[R] \f[B]E\f[R]
1133 The first two, or not specifying a \f[B]return\f[R] statement, is
1134 equivalent to \f[B]return (0)\f[R], unless the function is a
1135 \f[B]void\f[R] function (see the \f[I]Void Functions\f[R] subsection
1139 Functions can also be \f[B]void\f[R] functions, defined as follows:
1148 \f[R]
1154 Void functions can only use the first two \f[B]return\f[R] statements
1159 possible to have variables, arrays, and functions named \f[B]void\f[R].
1161 \f[B]define\f[R] keyword.
1163 This is a \f[B]non-portable extension\f[R].
1172 \f[R]
1175 it is a \f[B]reference\f[R].
1181 This is a \f[B]non-portable extension\f[R].
1185 library (see the \f[I]Extended Library\f[R] subsection below), are
1186 available when the \f[B]-l\f[R] or \f[B]--mathlib\f[R] command-line
1188 when the \f[B]-s\f[R] option, the \f[B]-w\f[R] option, or equivalents
1196 \f[B]s(x)\f[R]
1198 : Returns the sine of \f[B]x\f[R], which is assumed to be in radians.
1204 \f[R]
1207 \f[B]c(x)\f[R]
1209 : Returns the cosine of \f[B]x\f[R], which is assumed to be in radians.
1215 \f[R]
1218 \f[B]a(x)\f[R]
1220 : Returns the arctangent of \f[B]x\f[R], in radians.
1226 \f[R]
1229 \f[B]l(x)\f[R]
1231 : Returns the natural logarithm of \f[B]x\f[R].
1237 \f[R]
1240 \f[B]e(x)\f[R]
1242 : Returns the mathematical constant \f[B]e\f[R] raised to the power of
1243 \f[B]x\f[R].
1249 \f[R]
1252 \f[B]j(x, n)\f[R]
1254 : Returns the bessel integer order \f[B]n\f[R] (truncated) of
1255 \f[B]x\f[R].
1261 \f[R]
1265 The extended library is \f[I]not\f[R] loaded when the
1266 \f[B]-s\f[R]/\f[B]--standard\f[R] or \f[B]-w\f[R]/\f[B]--warn\f[R]
1270 The extended library is a \f[B]non-portable extension\f[R].
1272 \f[B]p(x, y)\f[R]
1274 : Calculates \f[B]x\f[R] to the power of \f[B]y\f[R], even if
1275 \f[B]y\f[R] is not an integer, and returns the result to the current
1276 \f[B]scale\f[R].
1284 \f[R]
1287 \f[B]r(x, p)\f[R]
1289 : Returns \f[B]x\f[R] rounded to \f[B]p\f[R] decimal places according to
1291 \f[B]0\f[R] (https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero).
1293 \f[B]ceil(x, p)\f[R]
1295 : Returns \f[B]x\f[R] rounded to \f[B]p\f[R] decimal places according to
1297 \f[B]0\f[R] (https://en.wikipedia.org/wiki/Rounding#Rounding_away_from_zero).
1299 \f[B]f(x)\f[R]
1301 : Returns the factorial of the truncated absolute value of \f[B]x\f[R].
1303 \f[B]perm(n, k)\f[R]
1305 : Returns the permutation of the truncated absolute value of \f[B]n\f[R]
1306 of the truncated absolute value of \f[B]k\f[R], if \f[B]k <= n\f[R].
1307 If not, it returns \f[B]0\f[R].
1309 \f[B]comb(n, k)\f[R]
1311 : Returns the combination of the truncated absolute value of \f[B]n\f[R]
1312 of the truncated absolute value of \f[B]k\f[R], if \f[B]k <= n\f[R].
1313 If not, it returns \f[B]0\f[R].
1315 \f[B]l2(x)\f[R]
1317 : Returns the logarithm base \f[B]2\f[R] of \f[B]x\f[R].
1323 \f[R]
1326 \f[B]l10(x)\f[R]
1328 : Returns the logarithm base \f[B]10\f[R] of \f[B]x\f[R].
1334 \f[R]
1337 \f[B]log(x, b)\f[R]
1339 : Returns the logarithm base \f[B]b\f[R] of \f[B]x\f[R].
1345 \f[R]
1348 \f[B]cbrt(x)\f[R]
1350 : Returns the cube root of \f[B]x\f[R].
1352 \f[B]root(x, n)\f[R]
1354 : Calculates the truncated value of \f[B]n\f[R], \f[B]r\f[R], and
1355 returns the \f[B]r\f[R]th root of \f[B]x\f[R] to the current
1356 \f[B]scale\f[R].
1360 If **r** is **0** or negative, this raises an error and causes bc(1) to
1362 to reset if **r** is even and **x** is negative.
1363 \f[R]
1366 \f[B]pi(p)\f[R]
1368 : Returns \f[B]pi\f[R] to \f[B]p\f[R] decimal places.
1374 \f[R]
1377 \f[B]t(x)\f[R]
1379 : Returns the tangent of \f[B]x\f[R], which is assumed to be in radians.
1385 \f[R]
1388 \f[B]a2(y, x)\f[R]
1390 : Returns the arctangent of \f[B]y/x\f[R], in radians.
1391 If both \f[B]y\f[R] and \f[B]x\f[R] are equal to \f[B]0\f[R], it raises
1392 an error and causes bc(1) to reset (see the \f[B]RESET\f[R] section).
1393 Otherwise, if \f[B]x\f[R] is greater than \f[B]0\f[R], it returns
1394 \f[B]a(y/x)\f[R].
1395 If \f[B]x\f[R] is less than \f[B]0\f[R], and \f[B]y\f[R] is greater than
1396 or equal to \f[B]0\f[R], it returns \f[B]a(y/x)+pi\f[R].
1397 If \f[B]x\f[R] is less than \f[B]0\f[R], and \f[B]y\f[R] is less than
1398 \f[B]0\f[R], it returns \f[B]a(y/x)-pi\f[R].
1399 If \f[B]x\f[R] is equal to \f[B]0\f[R], and \f[B]y\f[R] is greater than
1400 \f[B]0\f[R], it returns \f[B]pi/2\f[R].
1401 If \f[B]x\f[R] is equal to \f[B]0\f[R], and \f[B]y\f[R] is less than
1402 \f[B]0\f[R], it returns \f[B]-pi/2\f[R].
1411 \f[R]
1414 \f[B]sin(x)\f[R]
1416 : Returns the sine of \f[B]x\f[R], which is assumed to be in radians.
1424 \f[R]
1427 \f[B]cos(x)\f[R]
1429 : Returns the cosine of \f[B]x\f[R], which is assumed to be in radians.
1437 \f[R]
1440 \f[B]tan(x)\f[R]
1442 : Returns the tangent of \f[B]x\f[R], which is assumed to be in radians.
1446 If **x** is equal to **1** or **-1**, this raises an error and causes bc(1)
1453 \f[R]
1456 \f[B]atan(x)\f[R]
1458 : Returns the arctangent of \f[B]x\f[R], in radians.
1466 \f[R]
1469 \f[B]atan2(y, x)\f[R]
1471 : Returns the arctangent of \f[B]y/x\f[R], in radians.
1472 If both \f[B]y\f[R] and \f[B]x\f[R] are equal to \f[B]0\f[R], it raises
1473 an error and causes bc(1) to reset (see the \f[B]RESET\f[R] section).
1474 Otherwise, if \f[B]x\f[R] is greater than \f[B]0\f[R], it returns
1475 \f[B]a(y/x)\f[R].
1476 If \f[B]x\f[R] is less than \f[B]0\f[R], and \f[B]y\f[R] is greater than
1477 or equal to \f[B]0\f[R], it returns \f[B]a(y/x)+pi\f[R].
1478 If \f[B]x\f[R] is less than \f[B]0\f[R], and \f[B]y\f[R] is less than
1479 \f[B]0\f[R], it returns \f[B]a(y/x)-pi\f[R].
1480 If \f[B]x\f[R] is equal to \f[B]0\f[R], and \f[B]y\f[R] is greater than
1481 \f[B]0\f[R], it returns \f[B]pi/2\f[R].
1482 If \f[B]x\f[R] is equal to \f[B]0\f[R], and \f[B]y\f[R] is less than
1483 \f[B]0\f[R], it returns \f[B]-pi/2\f[R].
1494 \f[R]
1497 \f[B]r2d(x)\f[R]
1499 : Converts \f[B]x\f[R] from radians to degrees and returns the result.
1505 \f[R]
1508 \f[B]d2r(x)\f[R]
1510 : Converts \f[B]x\f[R] from degrees to radians and returns the result.
1516 \f[R]
1519 \f[B]frand(p)\f[R]
1521 : Generates a pseudo-random number between \f[B]0\f[R] (inclusive) and
1522 \f[B]1\f[R] (exclusive) with the number of decimal digits after the
1523 decimal point equal to the truncated absolute value of \f[B]p\f[R].
1524 If \f[B]p\f[R] is not \f[B]0\f[R], then calling this function will
1525 change the value of \f[B]seed\f[R].
1526 If \f[B]p\f[R] is \f[B]0\f[R], then \f[B]0\f[R] is returned, and
1527 \f[B]seed\f[R] is \f[I]not\f[R] changed.
1529 \f[B]ifrand(i, p)\f[R]
1531 : Generates a pseudo-random number that is between \f[B]0\f[R]
1532 (inclusive) and the truncated absolute value of \f[B]i\f[R] (exclusive)
1534 truncated absolute value of \f[B]p\f[R].
1535 If the absolute value of \f[B]i\f[R] is greater than or equal to
1536 \f[B]2\f[R], and \f[B]p\f[R] is not \f[B]0\f[R], then calling this
1537 function will change the value of \f[B]seed\f[R]; otherwise, \f[B]0\f[R]
1538 is returned and \f[B]seed\f[R] is not changed.
1540 \f[B]srand(x)\f[R]
1542 : Returns \f[B]x\f[R] with its sign flipped with probability
1543 \f[B]0.5\f[R].
1544 In other words, it randomizes the sign of \f[B]x\f[R].
1546 \f[B]brand()\f[R]
1548 : Returns a random boolean value (either \f[B]0\f[R] or \f[B]1\f[R]).
1550 \f[B]ubytes(x)\f[R]
1553 truncated absolute value of \f[B]x\f[R].
1555 \f[B]sbytes(x)\f[R]
1557 : Returns the numbers of signed, two\[aq]s-complement integer bytes
1558 required to hold the truncated value of \f[B]x\f[R].
1560 \f[B]hex(x)\f[R]
1562 : Outputs the hexadecimal (base \f[B]16\f[R]) representation of
1563 \f[B]x\f[R].
1569 \f[R]
1572 \f[B]binary(x)\f[R]
1574 : Outputs the binary (base \f[B]2\f[R]) representation of \f[B]x\f[R].
1580 \f[R]
1583 \f[B]output(x, b)\f[R]
1585 : Outputs the base \f[B]b\f[R] representation of \f[B]x\f[R].
1591 \f[R]
1594 \f[B]uint(x)\f[R]
1596 : Outputs the representation, in binary and hexadecimal, of \f[B]x\f[R]
1607 \f[R]
1610 \f[B]int(x)\f[R]
1612 : Outputs the representation, in binary and hexadecimal, of \f[B]x\f[R]
1613 as a signed, two\[aq]s-complement integer in as few power of two bytes
1624 \f[R]
1627 \f[B]uintn(x, n)\f[R]
1629 : Outputs the representation, in binary and hexadecimal, of \f[B]x\f[R]
1630 as an unsigned integer in \f[B]n\f[R] bytes.
1641 \f[R]
1644 \f[B]intn(x, n)\f[R]
1646 : Outputs the representation, in binary and hexadecimal, of \f[B]x\f[R]
1647 as a signed, two\[aq]s-complement integer in \f[B]n\f[R] bytes.
1657 \f[R]
1660 \f[B]uint8(x)\f[R]
1662 : Outputs the representation, in binary and hexadecimal, of \f[B]x\f[R]
1663 as an unsigned integer in \f[B]1\f[R] byte.
1674 \f[R]
1677 \f[B]int8(x)\f[R]
1679 : Outputs the representation, in binary and hexadecimal, of \f[B]x\f[R]
1680 as a signed, two\[aq]s-complement integer in \f[B]1\f[R] byte.
1690 \f[R]
1693 \f[B]uint16(x)\f[R]
1695 : Outputs the representation, in binary and hexadecimal, of \f[B]x\f[R]
1696 as an unsigned integer in \f[B]2\f[R] bytes.
1707 \f[R]
1710 \f[B]int16(x)\f[R]
1712 : Outputs the representation, in binary and hexadecimal, of \f[B]x\f[R]
1713 as a signed, two\[aq]s-complement integer in \f[B]2\f[R] bytes.
1723 \f[R]
1726 \f[B]uint32(x)\f[R]
1728 : Outputs the representation, in binary and hexadecimal, of \f[B]x\f[R]
1729 as an unsigned integer in \f[B]4\f[R] bytes.
1740 \f[R]
1743 \f[B]int32(x)\f[R]
1745 : Outputs the representation, in binary and hexadecimal, of \f[B]x\f[R]
1746 as a signed, two\[aq]s-complement integer in \f[B]4\f[R] bytes.
1756 \f[R]
1759 \f[B]uint64(x)\f[R]
1761 : Outputs the representation, in binary and hexadecimal, of \f[B]x\f[R]
1762 as an unsigned integer in \f[B]8\f[R] bytes.
1773 \f[R]
1776 \f[B]int64(x)\f[R]
1778 : Outputs the representation, in binary and hexadecimal, of \f[B]x\f[R]
1779 as a signed, two\[aq]s-complement integer in \f[B]8\f[R] bytes.
1789 \f[R]
1792 \f[B]hex_uint(x, n)\f[R]
1795 \f[B]x\f[R] as an unsigned integer in hexadecimal using \f[B]n\f[R]
1797 Not all of the value will be output if \f[B]n\f[R] is too small.
1803 \f[R]
1806 \f[B]binary_uint(x, n)\f[R]
1809 \f[B]x\f[R] as an unsigned integer in binary using \f[B]n\f[R] bytes.
1810 Not all of the value will be output if \f[B]n\f[R] is too small.
1816 \f[R]
1819 \f[B]output_uint(x, n)\f[R]
1822 \f[B]x\f[R] as an unsigned integer in the current \f[B]obase\f[R] (see
1823 the \f[B]SYNTAX\f[R] section) using \f[B]n\f[R] bytes.
1824 Not all of the value will be output if \f[B]n\f[R] is too small.
1830 \f[R]
1833 \f[B]output_byte(x, i)\f[R]
1835 : Outputs byte \f[B]i\f[R] of the truncated absolute value of
1836 \f[B]x\f[R], where \f[B]0\f[R] is the least significant byte and
1837 \f[B]number_of_bytes - 1\f[R] is the most significant byte.
1843 \f[R]
1855 functions with the precision (\f[B]scale\f[R]) set to at least 1 higher
1857 If exact results are \f[I]absolutely\f[R] required, users can double the
1858 precision (\f[B]scale\f[R]) and then truncate.
1862 \f[B]s(x)\f[R]
1864 \f[B]c(x)\f[R]
1866 \f[B]a(x)\f[R]
1868 \f[B]l(x)\f[R]
1870 \f[B]e(x)\f[R]
1872 \f[B]j(x, n)\f[R]
1876 \f[B]l2(x)\f[R]
1878 \f[B]l10(x)\f[R]
1880 \f[B]log(x, b)\f[R]
1882 \f[B]pi(p)\f[R]
1884 \f[B]t(x)\f[R]
1886 \f[B]a2(y, x)\f[R]
1888 \f[B]sin(x)\f[R]
1890 \f[B]cos(x)\f[R]
1892 \f[B]tan(x)\f[R]
1894 \f[B]atan(x)\f[R]
1896 \f[B]atan2(y, x)\f[R]
1898 \f[B]r2d(x)\f[R]
1900 \f[B]d2r(x)\f[R]
1903 When bc(1) encounters an error or a signal that it has a non-default
1916 (see the \f[B]EXIT STATUS\f[R] section), it asks for more input;
1924 Most bc(1) implementations use \f[B]char\f[R] types to calculate the
1925 value of \f[B]1\f[R] decimal digit at a time, but that can be slow.
1928 It uses large integers to calculate more than \f[B]1\f[R] decimal digit
1930 If built in a environment where \f[B]BC_LONG_BIT\f[R] (see the
1931 \f[B]LIMITS\f[R] section) is \f[B]64\f[R], then each integer has
1932 \f[B]9\f[R] decimal digits.
1933 If built in an environment where \f[B]BC_LONG_BIT\f[R] is \f[B]32\f[R]
1934 then each integer has \f[B]4\f[R] decimal digits.
1936 \f[B]BC_BASE_DIGS\f[R].
1938 The actual values of \f[B]BC_LONG_BIT\f[R] and \f[B]BC_BASE_DIGS\f[R]
1939 can be queried with the \f[B]limits\f[R] statement.
1943 This integer type depends on the value of \f[B]BC_LONG_BIT\f[R], but is
1949 \f[B]BC_LONG_BIT\f[R]
1951 : The number of bits in the \f[B]long\f[R] type in the environment where
1954 integer (see the \f[B]PERFORMANCE\f[R] section).
1956 \f[B]BC_BASE_DIGS\f[R]
1959 \f[B]PERFORMANCE\f[R] section).
1960 Depends on \f[B]BC_LONG_BIT\f[R].
1962 \f[B]BC_BASE_POW\f[R]
1965 \f[B]BC_BASE_DIGS\f[R]) plus \f[B]1\f[R].
1966 Depends on \f[B]BC_BASE_DIGS\f[R].
1968 \f[B]BC_OVERFLOW_MAX\f[R]
1970 : The max number that the overflow type (see the \f[B]PERFORMANCE\f[R]
1972 Depends on \f[B]BC_LONG_BIT\f[R].
1974 \f[B]BC_BASE_MAX\f[R]
1977 Set at \f[B]BC_BASE_POW\f[R].
1979 \f[B]BC_DIM_MAX\f[R]
1982 Set at \f[B]SIZE_MAX-1\f[R].
1984 \f[B]BC_SCALE_MAX\f[R]
1986 : The maximum \f[B]scale\f[R].
1987 Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
1989 \f[B]BC_STRING_MAX\f[R]
1992 Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
1994 \f[B]BC_NAME_MAX\f[R]
1997 Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
1999 \f[B]BC_NUM_MAX\f[R]
2003 Set at \f[B]BC_OVERFLOW_MAX-1\f[R].
2005 \f[B]BC_RAND_MAX\f[R]
2007 : The maximum integer (inclusive) returned by the \f[B]rand()\f[R]
2009 Set at \f[B]2\[ha]BC_LONG_BIT-1\f[R].
2014 Set at \f[B]BC_OVERFLOW_MAX\f[R].
2019 Set at \f[B]SIZE_MAX-1\f[R].
2021 The actual values can be queried with the \f[B]limits\f[R] statement.
2023 These limits are meant to be effectively non-existent; the limits are so
2024 large (at least on 64-bit machines) that there should not be any point
2031 \f[B]POSIXLY_CORRECT\f[R]
2034 the \f[B]-s\f[R] option was given.
2036 \f[B]BC_ENV_ARGS\f[R]
2038 : This is another way to give command-line arguments to bc(1).
2039 They should be in the same format as all other command-line arguments.
2041 \f[B]BC_ENV_ARGS\f[R] will be processed before arguments and files given
2042 on the command-line.
2061 command-line where the parsing is done by the shell.
2062 \f[R]
2065 \f[B]BC_LINE_LENGTH\f[R]
2068 greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
2069 (\f[B]2\[ha]16-1\f[R]), bc(1) will output lines to that length,
2070 including the backslash (\f[B]\[rs]\f[R]).
2071 The default line length is \f[B]70\f[R].
2076 \f[B]0\f[R]
2080 \f[B]1\f[R]
2083 This follows standard practice of using \f[B]1\f[R] for expected errors,
2089 number, using a negative number as a bound for the pseudo-random number
2092 use a non-integer where an integer is required.
2097 \f[R]
2100 \f[B]2\f[R]
2114 variable as a reference, and using any extensions when the option **-s** or
2116 \f[R]
2119 \f[B]3\f[R]
2130 \f[R]
2133 \f[B]4\f[R]
2142 and giving invalid command-line options.
2143 \f[R]
2146 The exit status \f[B]4\f[R] is special; when a fatal error occurs, bc(1)
2147 always exits and returns \f[B]4\f[R], no matter what mode bc(1) is in.
2150 interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
2151 bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
2154 \f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
2158 \f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
2163 bc(1) has an interactive mode and a non-interactive mode.
2164 Interactive mode is turned on automatically when both \f[B]stdin\f[R]
2165 and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
2166 and \f[B]--interactive\f[R] option can turn it on in other cases.
2169 \f[B]RESET\f[R] section), and in normal execution, flushes
2170 \f[B]stdout\f[R] as soon as execution is done for the current input.
2173 If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
2177 LINE HISTORY\f[R] section).
2178 It is also required to enable special handling for \f[B]SIGINT\f[R]
2184 and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
2188 Sending a \f[B]SIGINT\f[R] will cause bc(1) to stop execution of the
2190 If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
2191 reset (see the \f[B]RESET\f[R] section).
2195 If bc(1) is processing input from \f[B]stdin\f[R] in TTY mode, it will
2199 or ask for input from \f[B]stdin\f[R] if no other file exists.
2201 This means that if a \f[B]SIGINT\f[R] is sent to bc(1) as it is
2210 \f[B]SIGTERM\f[R] and \f[B]SIGQUIT\f[R] cause bc(1) to clean up and
2212 The one exception is \f[B]SIGHUP\f[R]; in that case, when bc(1) is in
2213 TTY mode, a \f[B]SIGHUP\f[R] will cause bc(1) to clean up and exit.
2216 bc(1) supports interactive command-line editing.
2217 If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), history is
2221 \f[B]Note\f[R]: tabs are converted to 8 spaces.
2227 bc(1) is compliant with the IEEE Std 1003.1-2017
2228 (\[lq]POSIX.1-2017\[rq]) (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
2230 The flags \f[B]-efghiqsvVw\f[R], all long options, and the extensions
2234 numbers that use a period (\f[B].\f[R]) as a radix point, regardless of
2235 the value of \f[B]LC_NUMERIC\f[R].