• Home
  • Raw
  • Download

Lines Matching +full:- +full:r

2 .\" SPDX-License-Identifier: BSD-2-Clause
4 .\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
31 dc - arbitrary-precision decimal reverse-Polish notation calculator
34 \f[B]dc\f[R] [\f[B]-hiPRvVx\f[R]] [\f[B]--version\f[R]]
35 [\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
36 [\f[B]--no-read-prompt\f[R]] [\f[B]--extended-register\f[R]]
37 [\f[B]-e\f[R] \f[I]expr\f[R]] [\f[B]--expression\f[R]=\f[I]expr\f[R]...]
38 [\f[B]-f\f[R] \f[I]file\f[R]...] [\f[B]--file\f[R]=\f[I]file\f[R]...]
39 [\f[I]file\f[R]...]
42 dc(1) is an arbitrary-precision calculator.
48 If no files are given on the command-line as extra arguments (i.e., not
49 as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
50 \f[B]stdin\f[R].
54 implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
55 \f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
58 the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
59 VARIABLES\f[R] section).
60 Any expressions given on the command-line should be used to set up a
62 For example, if a user wants the \f[B]scale\f[R] always set to
63 \f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]-e 10k\f[R],
64 and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
67 \f[B]-e\f[R] and \f[B]-f\f[R] arguments (and their equivalents), then
68 they can just simply add \f[B]-e q\f[R] as the last command-line
69 argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
74 \f[B]-h\f[R], \f[B]--help\f[R]
78 \f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
82 \f[B]-i\f[R], \f[B]--interactive\f[R]
85 (See the \f[B]INTERACTIVE MODE\f[R] section.)
89 This is a **non-portable extension**.
90 \f[R]
93 \f[B]-P\f[R], \f[B]--no-prompt\f[R]
97 See the \f[B]TTY MODE\f[R] section.) This is mostly for those users that
100 \f[B]DC_ENV_ARGS\f[R].
104 This is a **non-portable extension**.
105 \f[R]
108 \f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
112 See the \f[B]TTY MODE\f[R] section.) This is mostly for those users that
115 \f[B]BC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
124 This is a **non-portable extension**.
125 \f[R]
128 \f[B]-x\f[R] \f[B]--extended-register\f[R]
131 See the \f[I]Extended Register Mode\f[R] subsection of the
132 \f[B]REGISTERS\f[R] section for more information.
136 This is a **non-portable extension**.
137 \f[R]
140 \f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
142 : Evaluates \f[I]expr\f[R].
151 If this option is given on the command-line (i.e., not in **DC_ENV_ARGS**,
153 expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
154 as an argument at least once to **-f** or **-\[rs]-file**, whether on the
155 command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
156 **-\[rs]-expression**, **-f**, or **-\[rs]-file** arguments are given after **-f-**
159 This is a **non-portable extension**.
160 \f[R]
163 \f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
165 : Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
166 were read through \f[B]stdin\f[R].
172 If this option is given on the command-line (i.e., not in **DC_ENV_ARGS**,
174 expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
175 as an argument at least once to **-f** or **-\[rs]-file**. However, if any other
176 **-e**, **-\[rs]-expression**, **-f**, or **-\[rs]-file** arguments are given after
177 **-f-** or equivalent is given, dc(1) will give a fatal error and exit.
179 This is a **non-portable extension**.
180 \f[R]
183 All long options are \f[B]non-portable extensions\f[R].
186 Any non-error output is written to \f[B]stdout\f[R].
187 In addition, if history (see the \f[B]HISTORY\f[R] section) and the
188 prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
189 to \f[B]stdout\f[R].
191 \f[B]Note\f[R]: Unlike other dc(1) implementations, this dc(1) will
192 issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
193 write to \f[B]stdout\f[R], so if \f[B]stdout\f[R] is closed, as in
194 \f[B]dc >&-\f[R], it will quit with an error.
195 This is done so that dc(1) can report problems when \f[B]stdout\f[R] is
200 redirect \f[B]stdout\f[R] to \f[B]/dev/null\f[R].
203 Any error output is written to \f[B]stderr\f[R].
205 \f[B]Note\f[R]: Unlike other dc(1) implementations, this dc(1) will
206 issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
207 write to \f[B]stderr\f[R], so if \f[B]stderr\f[R] is closed, as in
208 \f[B]dc 2>&-\f[R], it will quit with an error.
210 \f[B]stderr\f[R] is redirected to a file.
214 redirect \f[B]stderr\f[R] to \f[B]/dev/null\f[R].
218 \f[B]NUMBERS\f[R] section) or a command (see the \f[B]COMMANDS\f[R]
222 \f[B]ibase\f[R] is a register (see the \f[B]REGISTERS\f[R] section) that
226 \f[B]ibase\f[R] is initially \f[B]10\f[R].
227 The max allowable value for \f[B]ibase\f[R] is \f[B]16\f[R].
228 The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
229 The max allowable value for \f[B]ibase\f[R] can be queried in dc(1)
230 programs with the \f[B]T\f[R] command.
232 \f[B]obase\f[R] is a register (see the \f[B]REGISTERS\f[R] section) that
236 \f[B]obase\f[R] is initially \f[B]10\f[R].
237 The max allowable value for \f[B]obase\f[R] is \f[B]DC_BASE_MAX\f[R] and
238 can be queried with the \f[B]U\f[R] command.
239 The min allowable value for \f[B]obase\f[R] is \f[B]0\f[R].
240 If \f[B]obase\f[R] is \f[B]0\f[R], values are output in scientific
241 notation, and if \f[B]obase\f[R] is \f[B]1\f[R], values are output in
245 Outputting in scientific and engineering notations are \f[B]non-portable
246 extensions\f[R].
248 The \f[I]scale\f[R] of an expression is the number of digits in the
249 result of the expression right of the decimal point, and \f[B]scale\f[R]
250 is a register (see the \f[B]REGISTERS\f[R] section) that sets the
252 \f[B]scale\f[R] is initially \f[B]0\f[R].
253 \f[B]scale\f[R] cannot be negative.
254 The max allowable value for \f[B]scale\f[R] can be queried in dc(1)
255 programs with the \f[B]V\f[R] command.
257 \f[B]seed\f[R] is a register containing the current seed for the
258 pseudo-random number generator.
259 If the current value of \f[B]seed\f[R] is queried and stored, then if it
260 is assigned to \f[B]seed\f[R] later, the pseudo-random number generator
261 is guaranteed to produce the same sequence of pseudo-random numbers that
262 were generated after the value of \f[B]seed\f[R] was first queried.
264 Multiple values assigned to \f[B]seed\f[R] can produce the same sequence
265 of pseudo-random numbers.
266 Likewise, when a value is assigned to \f[B]seed\f[R], it is not
267 guaranteed that querying \f[B]seed\f[R] immediately after will return
269 In addition, the value of \f[B]seed\f[R] will change after any call to
270 the \f[B]\[aq]\f[R] command or the \f[B]\[dq]\f[R] command that does not
271 get receive a value of \f[B]0\f[R] or \f[B]1\f[R].
272 The maximum integer returned by the \f[B]\[aq]\f[R] command can be
273 queried with the \f[B]W\f[R] command.
275 \f[B]Note\f[R]: The values returned by the pseudo-random number
276 generator with the \f[B]\[aq]\f[R] and \f[B]\[dq]\f[R] commands are
277 guaranteed to \f[B]NOT\f[R] be cryptographically secure.
278 This is a consequence of using a seeded pseudo-random number generator.
279 However, they \f[I]are\f[R] guaranteed to be reproducible with identical
280 \f[B]seed\f[R] values.
281 This means that the pseudo-random values from dc(1) should only be used
282 where a reproducible stream of pseudo-random numbers is
283 \f[I]ESSENTIAL\f[R].
284 In any other case, use a non-seeded pseudo-random number generator.
286 The pseudo-random number generator, \f[B]seed\f[R], and all associated
287 operations are \f[B]non-portable extensions\f[R].
290 Comments go from \f[B]#\f[R] until, and not including, the next newline.
291 This is a \f[B]non-portable extension\f[R].
295 \f[B]F\f[R], and at most \f[B]1\f[R] period for a radix.
296 Numbers can have up to \f[B]DC_NUM_MAX\f[R] digits.
297 Uppercase letters are equal to \f[B]9\f[R] + their position in the
298 alphabet (i.e., \f[B]A\f[R] equals \f[B]10\f[R], or \f[B]9+1\f[R]).
300 \f[B]ibase\f[R], they are set to the value of the highest valid digit in
301 \f[B]ibase\f[R].
303 Single-character numbers (i.e., \f[B]A\f[R] alone) take the value that
305 \f[B]ibase\f[R].
306 This means that \f[B]A\f[R] alone always equals decimal \f[B]10\f[R] and
307 \f[B]F\f[R] alone always equals decimal \f[B]15\f[R].
310 These have the form \f[B]<number>e<integer>\f[R].
311 The exponent (the portion after the \f[B]e\f[R]) must be an integer.
312 An example is \f[B]1.89237e9\f[R], which is equal to
313 \f[B]1892370000\f[R].
314 Negative exponents are also allowed, so \f[B]4.2890e_3\f[R] is equal to
315 \f[B]0.0042890\f[R].
317 \f[B]WARNING\f[R]: Both the number and the exponent in scientific
318 notation are interpreted according to the current \f[B]ibase\f[R], but
319 the number is still multiplied by \f[B]10\[ha]exponent\f[R] regardless
320 of the current \f[B]ibase\f[R].
321 For example, if \f[B]ibase\f[R] is \f[B]16\f[R] and dc(1) is given the
322 number string \f[B]FFeA\f[R], the resulting decimal number will be
323 \f[B]2550000000000\f[R], and if dc(1) is given the number string
324 \f[B]10e_4\f[R], the resulting decimal number will be \f[B]0.0016\f[R].
326 Accepting input as scientific notation is a \f[B]non-portable
327 extension\f[R].
337 Scientific notation is activated by assigning \f[B]0\f[R] to
338 \f[B]obase\f[R] using \f[B]0o\f[R], and engineering notation is
339 activated by assigning \f[B]1\f[R] to \f[B]obase\f[R] using
340 \f[B]1o\f[R].
341 To deactivate them, just assign a different value to \f[B]obase\f[R].
344 \f[B]non-portable extension\f[R].
346 \f[B]p\f[R]
354 \f[R]
357 \f[B]n\f[R]
362 \f[B]P\f[R]
374 This is a **non-portable extension**.
375 \f[R]
378 \f[B]f\f[R]
386 \f[R]
392 \f[B]+\f[R]
396 The \f[I]scale\f[R] of the result is equal to the max \f[I]scale\f[R] of
399 \f[B]-\f[R]
403 The \f[I]scale\f[R] of the result is equal to the max \f[I]scale\f[R] of
406 \f[B]*\f[R]
410 If \f[B]a\f[R] is the \f[I]scale\f[R] of the first expression and
411 \f[B]b\f[R] is the \f[I]scale\f[R] of the second expression, the
412 \f[I]scale\f[R] of the result is equal to
413 \f[B]min(a+b,max(scale,a,b))\f[R] where \f[B]min()\f[R] and
414 \f[B]max()\f[R] return the obvious values.
416 \f[B]/\f[R]
420 The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
424 The first value popped off of the stack must be non-zero.
425 \f[R]
428 \f[B]%\f[R]
436 2) Using the result of step 1 to calculate **a-(a/b)\[rs]*b** to *scale*
439 The first value popped off of the stack must be non-zero.
440 \f[R]
443 \f[B]\[ti]\f[R]
448 This is equivalent to \f[B]x y / x y %\f[R] except that \f[B]x\f[R] and
449 \f[B]y\f[R] are only evaluated once.
453 The first value popped off of the stack must be non-zero.
455 This is a **non-portable extension**.
456 \f[R]
459 \f[B]\[ha]\f[R]
463 The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
469 non-zero.
470 \f[R]
473 \f[B]v\f[R]
477 The \f[I]scale\f[R] of the result is equal to \f[B]scale\f[R].
481 The value popped off of the stack must be non-negative.
482 \f[R]
485 \f[B]_\f[R]
487 : If this command \f[I]immediately\f[R] precedes a number (i.e., no
495 **non-portable extension**.
496 \f[R]
499 \f[B]b\f[R]
507 This is a **non-portable extension**.
508 \f[R]
511 \f[B]|\f[R]
519 integer and non-zero. The second value popped is used as the exponent and
520 must be an integer and non-negative. The third value popped is the base and
523 This is a **non-portable extension**.
524 \f[R]
527 \f[B]$\f[R]
534 This is a **non-portable extension**.
535 \f[R]
538 \f[B]\[at]\f[R]
546 The first value popped off of the stack must be an integer and non-negative.
548 This is a **non-portable extension**.
549 \f[R]
552 \f[B]H\f[R]
559 The first value popped off of the stack must be an integer and non-negative.
561 This is a **non-portable extension**.
562 \f[R]
565 \f[B]h\f[R]
572 The first value popped off of the stack must be an integer and non-negative.
574 This is a **non-portable extension**.
575 \f[R]
578 \f[B]G\f[R]
581 a \f[B]1\f[R] is pushed if they are equal, or \f[B]0\f[R] otherwise.
585 This is a **non-portable extension**.
586 \f[R]
589 \f[B]N\f[R]
591 : The top value is popped off of the stack, and if it a \f[B]0\f[R], a
592 \f[B]1\f[R] is pushed; otherwise, a \f[B]0\f[R] is pushed.
596 This is a **non-portable extension**.
597 \f[R]
600 \f[B](\f[R]
603 a \f[B]1\f[R] is pushed if the first is less than the second, or
604 \f[B]0\f[R] otherwise.
608 This is a **non-portable extension**.
609 \f[R]
612 \f[B]{\f[R]
615 a \f[B]1\f[R] is pushed if the first is less than or equal to the
616 second, or \f[B]0\f[R] otherwise.
620 This is a **non-portable extension**.
621 \f[R]
624 \f[B])\f[R]
627 a \f[B]1\f[R] is pushed if the first is greater than the second, or
628 \f[B]0\f[R] otherwise.
632 This is a **non-portable extension**.
633 \f[R]
636 \f[B]}\f[R]
639 a \f[B]1\f[R] is pushed if the first is greater than or equal to the
640 second, or \f[B]0\f[R] otherwise.
644 This is a **non-portable extension**.
645 \f[R]
648 \f[B]M\f[R]
651 If they are both non-zero, a \f[B]1\f[R] is pushed onto the stack.
652 If either of them is zero, or both of them are, then a \f[B]0\f[R] is
657 This is like the **&&** operator in bc(1), and it is *not* a short-circuit
660 This is a **non-portable extension**.
661 \f[R]
664 \f[B]m\f[R]
667 If at least one of them is non-zero, a \f[B]1\f[R] is pushed onto the
669 If both of them are zero, then a \f[B]0\f[R] is pushed onto the stack.
673 This is like the **||** operator in bc(1), and it is *not* a short-circuit
676 This is a **non-portable extension**.
677 \f[R]
679 .SS Pseudo-Random Number Generator
681 dc(1) has a built-in pseudo-random number generator.
682 These commands query the pseudo-random number generator.
683 (See Parameters for more information about the \f[B]seed\f[R] value that
684 controls the pseudo-random number generator.)
686 The pseudo-random number generator is guaranteed to \f[B]NOT\f[R] be
689 \f[B]\[aq]\f[R]
691 : Generates an integer between 0 and \f[B]DC_RAND_MAX\f[R], inclusive
692 (see the \f[B]LIMITS\f[R] section).
697 limitations of the pseudo-random number generator.
699 This is a **non-portable extension**.
700 \f[R]
703 \f[B]\[dq]\f[R]
705 : Pops a value off of the stack, which is used as an \f[B]exclusive\f[R]
707 If the bound is negative or is a non-integer, an error is raised, and
708 dc(1) resets (see the \f[B]RESET\f[R] section) while \f[B]seed\f[R]
710 If the bound is larger than \f[B]DC_RAND_MAX\f[R], the higher bound is
711 honored by generating several pseudo-random integers, multiplying them
712 by appropriate powers of \f[B]DC_RAND_MAX+1\f[R], and adding them
716 Using this command will change the value of \f[B]seed\f[R], unless the
717 operand is \f[B]0\f[R] or \f[B]1\f[R].
718 In that case, \f[B]0\f[R] is pushed onto the stack, and \f[B]seed\f[R]
719 is \f[I]not\f[R] changed.
724 limitations of the pseudo-random number generator.
726 This is a **non-portable extension**.
727 \f[R]
733 \f[B]c\f[R]
737 \f[B]d\f[R]
742 \f[B]r\f[R]
746 \f[B]R\f[R]
751 These commands control registers (see the \f[B]REGISTERS\f[R] section).
753 \f[B]s\f[R]\f[I]r\f[R]
756 \f[I]r\f[R].
758 \f[B]l\f[R]\f[I]r\f[R]
760 : Copies the value in register \f[I]r\f[R] and pushes it onto the stack.
761 This does not alter the contents of \f[I]r\f[R].
763 \f[B]S\f[R]\f[I]r\f[R]
766 stack of register \f[I]r\f[R].
769 \f[B]L\f[R]\f[I]r\f[R]
771 : Pops the value off the top of the stack for register \f[I]r\f[R] and
773 The previous value in the stack for register \f[I]r\f[R], if any, is now
774 accessible via the \f[B]l\f[R]\f[I]r\f[R] command.
777 These commands control the values of \f[B]ibase\f[R], \f[B]obase\f[R],
778 \f[B]scale\f[R], and \f[B]seed\f[R].
779 Also see the \f[B]SYNTAX\f[R] section.
781 \f[B]i\f[R]
784 \f[B]ibase\f[R], which must be between \f[B]2\f[R] and \f[B]16\f[R],
790 \f[R]
793 \f[B]o\f[R]
796 \f[B]obase\f[R], which must be between \f[B]0\f[R] and
797 \f[B]DC_BASE_MAX\f[R], inclusive (see the \f[B]LIMITS\f[R] section and
798 the \f[B]NUMBERS\f[R] section).
803 \f[R]
806 \f[B]k\f[R]
809 \f[B]scale\f[R], which must be non-negative.
814 \f[R]
817 \f[B]j\f[R]
820 \f[B]seed\f[R].
821 The meaning of \f[B]seed\f[R] is dependent on the current pseudo-random
829 If a previously used **seed** value is used again, the pseudo-random number
830 generator is guaranteed to produce the same sequence of pseudo-random
836 sequence of pseudo-random numbers. This means that certain values assigned
837 to **seed** will not produce unique sequences of pseudo-random numbers.
842 This is a **non-portable extension**.
843 \f[R]
846 \f[B]I\f[R]
848 : Pushes the current value of \f[B]ibase\f[R] onto the main stack.
850 \f[B]O\f[R]
852 : Pushes the current value of \f[B]obase\f[R] onto the main stack.
854 \f[B]K\f[R]
856 : Pushes the current value of \f[B]scale\f[R] onto the main stack.
858 \f[B]J\f[R]
860 : Pushes the current value of \f[B]seed\f[R] onto the main stack.
864 This is a **non-portable extension**.
865 \f[R]
868 \f[B]T\f[R]
870 : Pushes the maximum allowable value of \f[B]ibase\f[R] onto the main
875 This is a **non-portable extension**.
876 \f[R]
879 \f[B]U\f[R]
881 : Pushes the maximum allowable value of \f[B]obase\f[R] onto the main
886 This is a **non-portable extension**.
887 \f[R]
890 \f[B]V\f[R]
892 : Pushes the maximum allowable value of \f[B]scale\f[R] onto the main
897 This is a **non-portable extension**.
898 \f[R]
901 \f[B]W\f[R]
904 \f[B]\[aq]\f[R] pseudo-random number generator command.
908 This is a **non-portable extension**.
909 \f[R]
916 \f[B]REGISTERS\f[R] section) can hold both strings and numbers.
924 For example, if the string \f[B][1pR]\f[R] is executed as a macro, then
925 the code \f[B]1pR\f[R] is executed, meaning that the \f[B]1\f[R] will be
928 \f[B][\f[R]\f[I]characters\f[R]\f[B]]\f[R]
930 : Makes a string containing \f[I]characters\f[R] and pushes it onto the
942 \f[R]
945 \f[B]a\f[R]
953 empty string; otherwise, push a one-character string where the character is
958 the original string is used to create the new string as a one-character
961 This is a **non-portable extension**.
962 \f[R]
965 \f[B]x\f[R]
977 \f[R]
980 \f[B]>\f[R]\f[I]r\f[R]
985 register \f[I]r\f[R] are executed.
994 \f[R]
997 \f[B]>\f[R]\f[I]r\f[R]\f[B]e\f[R]\f[I]s\f[R]
999 : Like the above, but will execute register \f[I]s\f[R] if the
1007 This is a **non-portable extension**.
1008 \f[R]
1011 \f[B]!>\f[R]\f[I]r\f[R]
1016 to), then the contents of register \f[I]r\f[R] are executed.
1022 \f[R]
1025 \f[B]!>\f[R]\f[I]r\f[R]\f[B]e\f[R]\f[I]s\f[R]
1027 : Like the above, but will execute register \f[I]s\f[R] if the
1035 This is a **non-portable extension**.
1036 \f[R]
1039 \f[B]<\f[R]\f[I]r\f[R]
1044 register \f[I]r\f[R] are executed.
1050 \f[R]
1053 \f[B]<\f[R]\f[I]r\f[R]\f[B]e\f[R]\f[I]s\f[R]
1055 : Like the above, but will execute register \f[I]s\f[R] if the
1063 This is a **non-portable extension**.
1064 \f[R]
1067 \f[B]!<\f[R]\f[I]r\f[R]
1072 to), then the contents of register \f[I]r\f[R] are executed.
1078 \f[R]
1081 \f[B]!<\f[R]\f[I]r\f[R]\f[B]e\f[R]\f[I]s\f[R]
1083 : Like the above, but will execute register \f[I]s\f[R] if the
1091 This is a **non-portable extension**.
1092 \f[R]
1095 \f[B]=\f[R]\f[I]r\f[R]
1100 \f[I]r\f[R] are executed.
1106 \f[R]
1109 \f[B]=\f[R]\f[I]r\f[R]\f[B]e\f[R]\f[I]s\f[R]
1111 : Like the above, but will execute register \f[I]s\f[R] if the
1119 This is a **non-portable extension**.
1120 \f[R]
1123 \f[B]!=\f[R]\f[I]r\f[R]
1128 register \f[I]r\f[R] are executed.
1134 \f[R]
1137 \f[B]!=\f[R]\f[I]r\f[R]\f[B]e\f[R]\f[I]s\f[R]
1139 : Like the above, but will execute register \f[I]s\f[R] if the
1147 This is a **non-portable extension**.
1148 \f[R]
1151 \f[B]?\f[R]
1153 : Reads a line from the \f[B]stdin\f[R] and executes it.
1156 \f[B]q\f[R]
1162 \f[B]Q\f[R]
1164 : Pops a value from the stack which must be non-negative and is used the
1172 \f[B]Z\f[R]
1182 \f[R]
1185 \f[B]X\f[R]
1194 \f[R]
1197 \f[B]z\f[R]
1204 \f[B]:\f[R]\f[I]r\f[R]
1207 The second value will be stored in the array \f[I]r\f[R] (see the
1208 \f[B]REGISTERS\f[R] section), indexed by the first value.
1210 \f[B];\f[R]\f[I]r\f[R]
1213 array \f[I]r\f[R].
1222 All registers, when first referenced, have one value (\f[B]0\f[R]) in
1225 In non-extended register mode, a register name is just the single
1227 The only exception is a newline (\f[B]\[aq]\[rs]n\[aq]\f[R]); it is a
1234 If extended register mode is enabled (\f[B]-x\f[R] or
1235 \f[B]--extended-register\f[R] command-line arguments are given), then
1236 normal single character registers are used \f[I]unless\f[R] the
1238 a space (according to \f[B]isspace()\f[R]) and not a newline
1239 (\f[B]\[aq]\[rs]n\[aq]\f[R]).
1242 \f[B][a-z][a-z0-9_]*\f[R] (like bc(1) identifiers), and it is a parse
1243 error if the next non-space characters do not match that regex.
1246 When dc(1) encounters an error or a signal that it has a non-default
1259 (see the \f[B]EXIT STATUS\f[R] section), it asks for more input;
1263 Most dc(1) implementations use \f[B]char\f[R] types to calculate the
1264 value of \f[B]1\f[R] decimal digit at a time, but that can be slow.
1267 It uses large integers to calculate more than \f[B]1\f[R] decimal digit
1269 If built in a environment where \f[B]DC_LONG_BIT\f[R] (see the
1270 \f[B]LIMITS\f[R] section) is \f[B]64\f[R], then each integer has
1271 \f[B]9\f[R] decimal digits.
1272 If built in an environment where \f[B]DC_LONG_BIT\f[R] is \f[B]32\f[R]
1273 then each integer has \f[B]4\f[R] decimal digits.
1275 \f[B]DC_BASE_DIGS\f[R].
1279 This integer type depends on the value of \f[B]DC_LONG_BIT\f[R], but is
1285 \f[B]DC_LONG_BIT\f[R]
1287 : The number of bits in the \f[B]long\f[R] type in the environment where
1290 integer (see the \f[B]PERFORMANCE\f[R] section).
1292 \f[B]DC_BASE_DIGS\f[R]
1295 \f[B]PERFORMANCE\f[R] section).
1296 Depends on \f[B]DC_LONG_BIT\f[R].
1298 \f[B]DC_BASE_POW\f[R]
1301 \f[B]DC_BASE_DIGS\f[R]) plus \f[B]1\f[R].
1302 Depends on \f[B]DC_BASE_DIGS\f[R].
1304 \f[B]DC_OVERFLOW_MAX\f[R]
1306 : The max number that the overflow type (see the \f[B]PERFORMANCE\f[R]
1308 Depends on \f[B]DC_LONG_BIT\f[R].
1310 \f[B]DC_BASE_MAX\f[R]
1313 Set at \f[B]DC_BASE_POW\f[R].
1315 \f[B]DC_DIM_MAX\f[R]
1318 Set at \f[B]SIZE_MAX-1\f[R].
1320 \f[B]DC_SCALE_MAX\f[R]
1322 : The maximum \f[B]scale\f[R].
1323 Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
1325 \f[B]DC_STRING_MAX\f[R]
1328 Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
1330 \f[B]DC_NAME_MAX\f[R]
1333 Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
1335 \f[B]DC_NUM_MAX\f[R]
1339 Set at \f[B]DC_OVERFLOW_MAX-1\f[R].
1341 \f[B]DC_RAND_MAX\f[R]
1343 : The maximum integer (inclusive) returned by the \f[B]\[aq]\f[R]
1345 Set at \f[B]2\[ha]DC_LONG_BIT-1\f[R].
1350 Set at \f[B]DC_OVERFLOW_MAX\f[R].
1355 Set at \f[B]SIZE_MAX-1\f[R].
1357 These limits are meant to be effectively non-existent; the limits are so
1358 large (at least on 64-bit machines) that there should not be any point
1365 \f[B]DC_ENV_ARGS\f[R]
1367 : This is another way to give command-line arguments to dc(1).
1368 They should be in the same format as all other command-line arguments.
1370 \f[B]DC_ENV_ARGS\f[R] will be processed before arguments and files given
1371 on the command-line.
1376 Another use would be to use the \f[B]-e\f[R] option to set
1377 \f[B]scale\f[R] to a value other than \f[B]0\f[R].
1392 command-line where the parsing is done by the shell.
1393 \f[R]
1396 \f[B]DC_LINE_LENGTH\f[R]
1399 greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
1400 (\f[B]2\[ha]16-1\f[R]), dc(1) will output lines to that length,
1402 The default line length is \f[B]70\f[R].
1404 \f[B]DC_EXPR_EXIT\f[R]
1408 \f[B]-e\f[R] and/or \f[B]-f\f[R] command-line options (and any
1414 \f[B]0\f[R]
1418 \f[B]1\f[R]
1421 This follows standard practice of using \f[B]1\f[R] for expected errors,
1427 number, using a negative number as a bound for the pseudo-random number
1430 use a non-integer where an integer is required.
1435 \f[R]
1438 \f[B]2\f[R]
1447 \f[R]
1450 \f[B]3\f[R]
1460 \f[R]
1463 \f[B]4\f[R]
1472 and giving invalid command-line options.
1473 \f[R]
1476 The exit status \f[B]4\f[R] is special; when a fatal error occurs, dc(1)
1477 always exits and returns \f[B]4\f[R], no matter what mode dc(1) is in.
1480 interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
1481 dc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
1484 \f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
1488 \f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
1491 Like bc(1), dc(1) has an interactive mode and a non-interactive mode.
1492 Interactive mode is turned on automatically when both \f[B]stdin\f[R]
1493 and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
1494 and \f[B]--interactive\f[R] option can turn it on in other cases.
1497 \f[B]RESET\f[R] section), and in normal execution, flushes
1498 \f[B]stdout\f[R] as soon as execution is done for the current input.
1501 If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
1505 LINE HISTORY\f[R] section).
1506 It is also required to enable special handling for \f[B]SIGINT\f[R]
1514 and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
1518 Sending a \f[B]SIGINT\f[R] will cause dc(1) to stop execution of the
1520 If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
1521 reset (see the \f[B]RESET\f[R] section).
1525 If dc(1) is processing input from \f[B]stdin\f[R] in TTY mode, it will
1529 or ask for input from \f[B]stdin\f[R] if no other file exists.
1531 This means that if a \f[B]SIGINT\f[R] is sent to dc(1) as it is
1540 \f[B]SIGTERM\f[R] and \f[B]SIGQUIT\f[R] cause dc(1) to clean up and
1542 The one exception is \f[B]SIGHUP\f[R]; in that case, when dc(1) is in
1543 TTY mode, a \f[B]SIGHUP\f[R] will cause dc(1) to clean up and exit.
1546 dc(1) supports interactive command-line editing.
1547 If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), history is
1551 \f[B]Note\f[R]: tabs are converted to 8 spaces.
1555 locales and thus, supports \f[B]LC_MESSAGS\f[R].
1562 bc(1) IEEE Std 1003.1-2017
1563 (\[lq]POSIX.1-2017\[rq]) (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)