Lines Matching +full:dc +full:- +full:valid

2 .\" SPDX-License-Identifier: BSD-2-Clause
4 .\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
28 .TH "DC" "1" "August 2024" "Gavin D. Howard" "General Commands Manual"
32 dc \- arbitrary\-precision decimal reverse\-Polish notation calculator
34 \f[B]dc\f[R] [\f[B]\-cChiPRvVx\f[R]] [\f[B]\-\-version\f[R]]
35 [\f[B]\-\-help\f[R]] [\f[B]\-\-digit\-clamp\f[R]]
36 [\f[B]\-\-no\-digit\-clamp\f[R]] [\f[B]\-\-interactive\f[R]]
37 [\f[B]\-\-no\-prompt\f[R]] [\f[B]\-\-no\-read\-prompt\f[R]]
38 [\f[B]\-\-extended\-register\f[R]] [\f[B]\-e\f[R] \f[I]expr\f[R]]
39 [\f[B]\-\-expression\f[R]=\f[I]expr\f[R]\&...]
40 [\f[B]\-f\f[R] \f[I]file\f[R]\&...]
41 [\f[B]\-\-file\f[R]=\f[I]file\f[R]\&...]
43 [\f[B]\-I\f[R] \f[I]ibase\f[R]] [\f[B]\-\-ibase\f[R]=\f[I]ibase\f[R]]
44 [\f[B]\-O\f[R] \f[I]obase\f[R]] [\f[B]\-\-obase\f[R]=\f[I]obase\f[R]]
45 [\f[B]\-S\f[R] \f[I]scale\f[R]] [\f[B]\-\-scale\f[R]=\f[I]scale\f[R]]
46 [\f[B]\-E\f[R] \f[I]seed\f[R]] [\f[B]\-\-seed\f[R]=\f[I]seed\f[R]]
48 dc(1) is an arbitrary\-precision calculator.
54 If no files are given on the command\-line, then dc(1) reads from
56 Otherwise, those files are processed, and dc(1) will then exit.
61 \f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]\-e 10k\f[R],
62 and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
64 The following are the options that dc(1) accepts.
66 \f[B]\-C\f[R], \f[B]\-\-no\-digit\-clamp\f[R]
76 If this and/or the \f[B]\-c\f[R] or \f[B]\-\-digit\-clamp\f[R] options
81 can be queried with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
83 This is a \f[B]non\-portable extension\f[R].
86 \f[B]\-c\f[R], \f[B]\-\-digit\-clamp\f[R]
97 If this and/or the \f[B]\-C\f[R] or \f[B]\-\-no\-digit\-clamp\f[R]
102 can be queried with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
104 This is a \f[B]non\-portable extension\f[R].
107 \f[B]\-E\f[R] \f[I]seed\f[R], \f[B]\-\-seed\f[R]=\f[I]seed\f[R]
110 It is a fatal error if \f[I]seed\f[R] is not a valid number.
115 This is a \f[B]non\-portable extension\f[R].
118 \f[B]\-e\f[R] \f[I]expr\f[R], \f[B]\-\-expression\f[R]=\f[I]expr\f[R]
127 If this option is given on the command\-line (i.e., not in
129 then after processing all expressions and files, dc(1) will exit, unless
130 \f[B]\-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
131 \f[B]\-f\f[R] or \f[B]\-\-file\f[R], whether on the command\-line or in
133 However, if any other \f[B]\-e\f[R], \f[B]\-\-expression\f[R],
134 \f[B]\-f\f[R], or \f[B]\-\-file\f[R] arguments are given after
135 \f[B]\-f\-\f[R] or equivalent is given, dc(1) will give a fatal error
138 This is a \f[B]non\-portable extension\f[R].
141 \f[B]\-f\f[R] \f[I]file\f[R], \f[B]\-\-file\f[R]=\f[I]file\f[R]
148 If this option is given on the command\-line (i.e., not in
150 then after processing all expressions and files, dc(1) will exit, unless
151 \f[B]\-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
152 \f[B]\-f\f[R] or \f[B]\-\-file\f[R].
153 However, if any other \f[B]\-e\f[R], \f[B]\-\-expression\f[R],
154 \f[B]\-f\f[R], or \f[B]\-\-file\f[R] arguments are given after
155 \f[B]\-f\-\f[R] or equivalent is given, dc(1) will give a fatal error
158 This is a \f[B]non\-portable extension\f[R].
161 \f[B]\-h\f[R], \f[B]\-\-help\f[R]
164 \f[B]\-I\f[R] \f[I]ibase\f[R], \f[B]\-\-ibase\f[R]=\f[I]ibase\f[R]
167 It is a fatal error if \f[I]ibase\f[R] is not a valid number.
172 This is a \f[B]non\-portable extension\f[R].
175 \f[B]\-i\f[R], \f[B]\-\-interactive\f[R]
180 This is a \f[B]non\-portable extension\f[R].
183 \f[B]\-L\f[R], \f[B]\-\-no\-line\-length\f[R]
190 This is a \f[B]non\-portable extension\f[R].
193 \f[B]\-O\f[R] \f[I]obase\f[R], \f[B]\-\-obase\f[R]=\f[I]obase\f[R]
196 It is a fatal error if \f[I]obase\f[R] is not a valid number.
201 This is a \f[B]non\-portable extension\f[R].
204 \f[B]\-P\f[R], \f[B]\-\-no\-prompt\f[R]
209 to having them in dc(1).
217 This is a \f[B]non\-portable extension\f[R].
220 \f[B]\-R\f[R], \f[B]\-\-no\-read\-prompt\f[R]
225 used to having them in dc(1).
228 This option is also useful in hash bang lines of dc(1) scripts that
239 This is a \f[B]non\-portable extension\f[R].
242 \f[B]\-S\f[R] \f[I]scale\f[R], \f[B]\-\-scale\f[R]=\f[I]scale\f[R]
245 It is a fatal error if \f[I]scale\f[R] is not a valid number.
250 This is a \f[B]non\-portable extension\f[R].
253 \f[B]\-v\f[R], \f[B]\-V\f[R], \f[B]\-\-version\f[R]
256 \f[B]\-x\f[R] \f[B]\-\-extended\-register\f[R]
262 This is a \f[B]non\-portable extension\f[R].
265 \f[B]\-z\f[R], \f[B]\-\-leading\-zeroes\f[R]
266 Makes dc(1) print all numbers greater than \f[B]\-1\f[R] and less than
270 This is a \f[B]non\-portable extension\f[R].
273 All long options are \f[B]non\-portable extensions\f[R].
275 If no files are given on the command\-line and no files or expressions
276 are given by the \f[B]\-f\f[R], \f[B]\-\-file\f[R], \f[B]\-e\f[R], or
277 \f[B]\-\-expression\f[R] options, then dc(1) reads from \f[B]stdin\f[R].
285 balanced before dc(1) parses and executes.
287 Any non\-error output is written to \f[B]stdout\f[R].
292 \f[B]Note\f[R]: Unlike other dc(1) implementations, this dc(1) will
295 \f[B]dc >&\-\f[R], it will quit with an error.
296 This is done so that dc(1) can report problems when \f[B]stdout\f[R] is
299 If there are scripts that depend on the behavior of other dc(1)
305 \f[B]Note\f[R]: Unlike other dc(1) implementations, this dc(1) will
308 \f[B]dc 2>&\-\f[R], it will quit with an error.
309 This is done so that dc(1) can exit with an error code when
312 If there are scripts that depend on the behavior of other dc(1)
328 The max allowable value for \f[B]ibase\f[R] can be queried in dc(1)
345 \f[B]non\-portable extensions\f[R].
353 The max allowable value for \f[B]scale\f[R] can be queried in dc(1)
357 pseudo\-random number generator.
359 is assigned to \f[B]seed\f[R] later, the pseudo\-random number generator
360 is guaranteed to produce the same sequence of pseudo\-random numbers
364 of pseudo\-random numbers.
374 \f[B]Note\f[R]: The values returned by the pseudo\-random number
377 This is a consequence of using a seeded pseudo\-random number generator.
380 This means that the pseudo\-random values from dc(1) should only be used
381 where a reproducible stream of pseudo\-random numbers is
383 In any other case, use a non\-seeded pseudo\-random number generator.
385 The pseudo\-random number generator, \f[B]seed\f[R], and all associated
386 operations are \f[B]non\-portable extensions\f[R].
389 This is a \f[B]non\-portable extension\f[R].
400 the \f[B]\-c\f[R]/\f[B]\-\-digit\-clamp\f[R] or
401 \f[B]\-C\f[R]/\f[B]\-\-no\-digit\-clamp\f[R] options (see the
405 \f[B]\-h\f[R]/\f[B]\-\-help\f[R] option.
417 highest valid digit in \f[B]ibase\f[R] before being multiplied by the
423 There is one exception to clamping: single\-character numbers (i.e.,
437 In addition, dc(1) accepts numbers in scientific notation.
449 For example, if \f[B]ibase\f[R] is \f[B]16\f[R] and dc(1) is given the
451 \f[B]2550000000000\f[R], and if dc(1) is given the number string
454 Accepting input as scientific notation is a \f[B]non\-portable
457 The valid commands are listed below.
470 \f[B]non\-portable extension\f[R].
490 digit is interpreted as an 8\-bit ASCII character, making it a byte
495 This is a \f[B]non\-portable extension\f[R].
514 \f[B]\-\f[R]
535 The first value popped off of the stack must be non\-zero.
545 \f[B]a\-(a/b)*b\f[R] to \f[I]scale\f[R]
548 The first value popped off of the stack must be non\-zero.
559 The first value popped off of the stack must be non\-zero.
561 This is a \f[B]non\-portable extension\f[R].
572 non\-zero.
581 The value popped off of the stack must be non\-negative.
591 This behavior without a number is a \f[B]non\-portable extension\f[R].
600 This is a \f[B]non\-portable extension\f[R].
609 integer and non\-zero.
611 and non\-negative.
614 This is a \f[B]non\-portable extension\f[R].
622 This is a \f[B]non\-portable extension\f[R].
632 non\-negative.
634 This is a \f[B]non\-portable extension\f[R].
643 non\-negative.
645 This is a \f[B]non\-portable extension\f[R].
654 non\-negative.
656 This is a \f[B]non\-portable extension\f[R].
664 This is a \f[B]non\-portable extension\f[R].
672 This is a \f[B]non\-portable extension\f[R].
681 This is a \f[B]non\-portable extension\f[R].
690 This is a \f[B]non\-portable extension\f[R].
699 This is a \f[B]non\-portable extension\f[R].
708 This is a \f[B]non\-portable extension\f[R].
713 If they are both non\-zero, a \f[B]1\f[R] is pushed onto the stack.
719 a short\-circuit operator.
721 This is a \f[B]non\-portable extension\f[R].
726 If at least one of them is non\-zero, a \f[B]1\f[R] is pushed onto the
732 a short\-circuit operator.
734 This is a \f[B]non\-portable extension\f[R].
736 .SS Pseudo\-Random Number Generator
737 dc(1) has a built\-in pseudo\-random number generator.
738 These commands query the pseudo\-random number generator.
740 controls the pseudo\-random number generator.)
742 The pseudo\-random number generator is guaranteed to \f[B]NOT\f[R] be
751 limitations of the pseudo\-random number generator.
753 This is a \f[B]non\-portable extension\f[R].
759 If the bound is negative or is a non\-integer, an error is raised, and
763 honored by generating several pseudo\-random integers, multiplying them
775 limitations of the pseudo\-random number generator.
777 This is a \f[B]non\-portable extension\f[R].
843 \f[B]scale\f[R], which must be non\-negative.
853 The meaning of \f[B]seed\f[R] is dependent on the current pseudo\-random
861 pseudo\-random number generator is guaranteed to produce the same
862 sequence of pseudo\-random numbers as it did when the \f[B]seed\f[R]
869 same sequence of pseudo\-random numbers.
871 produce unique sequences of pseudo\-random numbers.
876 This is a \f[B]non\-portable extension\f[R].
892 This is a \f[B]non\-portable extension\f[R].
900 This is a \f[B]non\-portable extension\f[R].
908 This is a \f[B]non\-portable extension\f[R].
916 This is a \f[B]non\-portable extension\f[R].
921 \f[B]\[cq]\f[R] pseudo\-random number generator command.
924 This is a \f[B]non\-portable extension\f[R].
964 one\-character string where the character is the result of the mod
970 create the new string as a one\-character string.
973 This is a \f[B]non\-portable extension\f[R].
997 If either or both of the values are not numbers, dc(1) will raise an
1006 If either or both of the values are not numbers, dc(1) will raise an
1009 This is a \f[B]non\-portable extension\f[R].
1018 If either or both of the values are not numbers, dc(1) will raise an
1027 If either or both of the values are not numbers, dc(1) will raise an
1030 This is a \f[B]non\-portable extension\f[R].
1039 If either or both of the values are not numbers, dc(1) will raise an
1048 If either or both of the values are not numbers, dc(1) will raise an
1051 This is a \f[B]non\-portable extension\f[R].
1060 If either or both of the values are not numbers, dc(1) will raise an
1069 If either or both of the values are not numbers, dc(1) will raise an
1072 This is a \f[B]non\-portable extension\f[R].
1081 If either or both of the values are not numbers, dc(1) will raise an
1090 If either or both of the values are not numbers, dc(1) will raise an
1093 This is a \f[B]non\-portable extension\f[R].
1102 If either or both of the values are not numbers, dc(1) will raise an
1111 If either or both of the values are not numbers, dc(1) will raise an
1114 This is a \f[B]non\-portable extension\f[R].
1124 If there are no macros, or only one macro executing, dc(1) exits.
1127 Pops a value from the stack which must be non\-negative and is used the
1130 macros, dc(1) exits.
1136 to make dc(1) exit with the \f[B]Q\f[R] command, so the sequence
1137 \f[B],Q\f[R] will make dc(1) exit.
1140 This is a \f[B]non\-portable extension\f[R].
1173 This is a \f[B]non\-portable extension\f[R].
1182 This is a \f[B]non\-portable extension\f[R].
1195 \f[B]0\f[R] in the top item) when dc(1) starts, dc(1) requires that each
1196 register\[cq]s stack must always have at least one item; dc(1) will give
1200 This is a \f[B]non\-portable extension\f[R].
1219 This is a \f[B]non\-portable extension\f[R].
1241 been enabled with the \f[B]\-z\f[R] or \f[B]\-\-leading\-zeroes\f[R]
1242 options (see the \f[B]OPTIONS\f[R] section), non\-zero otherwise.
1253 In non\-extended register mode, a register name is just the single
1259 Unlike most other dc(1) implentations, this dc(1) provides nearly
1262 If extended register mode is enabled (\f[B]\-x\f[R] or
1263 \f[B]\-\-extended\-register\f[R] command\-line arguments are given),
1270 \f[B][a\-z][a\-z0\-9_]*\f[R] (like bc(1) identifiers), and it is a parse
1271 error if the next non\-space characters do not match that regex.
1273 When dc(1) encounters an error or a signal that it has a non\-default
1286 Thus, when dc(1) resets, it skips any remaining code waiting to be
1292 Most dc(1) implementations use \f[B]char\f[R] types to calculate the
1294 This dc(1) does something different.
1306 In addition, this dc(1) uses an even larger integer for overflow
1311 The following are the limits on dc(1):
1340 Set at \f[B]SIZE_MAX\-1\f[R].
1344 Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
1348 Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
1352 Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
1357 Set at \f[B]DC_OVERFLOW_MAX\-1\f[R].
1361 if dc(1).
1362 Set at \f[B]2\[ha]DC_LONG_BIT\-1\f[R].
1370 Set at \f[B]SIZE_MAX\-1\f[R].
1372 These limits are meant to be effectively non\-existent; the limits are
1373 so large (at least on 64\-bit machines) that there should not be any
1377 As \f[B]non\-portable extensions\f[R], dc(1) recognizes the following
1381 This is another way to give command\-line arguments to dc(1).
1382 They should be in the same format as all other command\-line arguments.
1385 on the command\-line.
1389 functions that the user might want every time dc(1) runs.
1390 Another use would be to use the \f[B]\-e\f[R] option to set
1396 For example, the string \f[B]\[lq]/home/gavin/some dc file.dc\[rq]\f[R]
1398 \[dq]dc\[dq] file.dc\[rq]\f[R] will include the backslashes.
1404 `dc' file.dc\[rq]\f[R], and vice versa if you have a file with double
1408 parsing, though such files are still supported on the command\-line
1415 (\f[B]2\[ha]16\-1\f[R]), dc(1) will output lines to that length,
1426 If dc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
1427 section), then this environment variable has no effect because dc(1)
1431 However, when dc(1) is in interactive mode, then if this environment
1432 variable exists and contains an integer, a non\-zero value makes dc(1)
1433 reset on \f[B]SIGINT\f[R], rather than exit, and zero makes dc(1) exit.
1435 then dc(1) will exit on \f[B]SIGINT\f[R].
1438 with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
1447 exists and contains an integer, then a non\-zero value makes dc(1) use
1448 TTY mode, and zero makes dc(1) not use TTY mode.
1451 with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
1460 exists and contains an integer, a non\-zero value makes dc(1) use a
1461 prompt, and zero or a non\-integer makes dc(1) not use a prompt.
1468 \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
1472 If any expressions or expression files are given on the command\-line
1473 with \f[B]\-e\f[R], \f[B]\-\-expression\f[R], \f[B]\-f\f[R], or
1474 \f[B]\-\-file\f[R], then if this environment variable exists and
1475 contains an integer, a non\-zero value makes dc(1) exit after executing
1476 the expressions and expression files, and a zero value makes dc(1) not
1481 with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
1486 contains an integer, a non\-zero value makes dc(1) clamp digits that are
1493 This never applies to single\-digit numbers, as per the bc(1) standard
1497 with the \f[B]\-h\f[R] or \f[B]\-\-help\f[R] options.
1513 pseudo\-random number generator, attempting to convert a negative number
1516 to use a non\-integer where an integer is required.
1550 characters (dc(1) only accepts ASCII characters), attempting to open a
1551 directory as a file, and giving invalid command\-line options.
1554 The exit status \f[B]4\f[R] is special; when a fatal error occurs, dc(1)
1555 always exits and returns \f[B]4\f[R], no matter what mode dc(1) is in.
1557 The other statuses will only be returned when dc(1) is not in
1562 \f[B]\-i\f[R] flag or \f[B]\-\-interactive\f[R] option.
1564 These exit statuses allow dc(1) to be used in shell scripting with error
1566 \f[B]\-i\f[R] flag or \f[B]\-\-interactive\f[R] option.
1568 Like bc(1), dc(1) has an interactive mode and a non\-interactive mode.
1570 and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]\-i\f[R]
1571 flag and \f[B]\-\-interactive\f[R] option can turn it on in other
1574 In interactive mode, dc(1) attempts to recover from errors (see the
1583 available, and thus, dc(1) can turn on TTY mode, subject to some
1588 that environment variable contains a non\-zero integer, dc(1) will turn
1592 \f[I]not\f[R] a non\-zero integer, then dc(1) will not turn TTY mode on.
1596 The default setting can be queried with the \f[B]\-h\f[R] or
1597 \f[B]\-\-help\f[R] options.
1610 non\-zero integer, then the prompt is turned on when \f[B]stdin\f[R],
1612 \f[B]\-P\f[R] and \f[B]\-\-no\-prompt\f[R] options were not used.
1614 the \f[B]\-R\f[R] and \f[B]\-\-no\-read\-prompt\f[R] options must also
1619 the \f[B]\-P\f[R] and \f[B]\-\-no\-prompt\f[R] options, and the
1620 \f[B]\-R\f[R] and \f[B]\-\-no\-read\-prompt\f[R] options.
1624 Sending a \f[B]SIGINT\f[R] will cause dc(1) to do one of two things.
1626 If dc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
1629 an integer or it is zero, dc(1) will exit.
1631 However, if dc(1) is in interactive mode, and the
1632 \f[B]DC_SIGINT_RESET\f[R] or its default is an integer and non\-zero,
1633 then dc(1) will stop executing the current input and reset (see the
1637 If dc(1) is processing input from \f[B]stdin\f[R] in interactive mode,
1639 If dc(1) is processing input from a file in interactive mode, it will
1643 This means that if a \f[B]SIGINT\f[R] is sent to dc(1) as it is
1644 executing a file, it can seem as though dc(1) did not respond to the
1652 \f[B]SIGTERM\f[R] and \f[B]SIGQUIT\f[R] cause dc(1) to clean up and
1657 The dc(1) utility operators and some behavior are compliant with the
1658 operators in the IEEE Std 1003.1\-2017 (\[lq]POSIX.1\-2017\[rq]) bc(1)