Lines Matching +full:disable +full:- +full:dc

1 <!---
3 SPDX-License-Identifier: BSD-2-Clause
5 Copyright (c) 2018-2024 Gavin D. Howard and contributors.
29 -->
33 dc - arbitrary-precision decimal reverse-Polish notation calculator
37dc** [**-cChiPRvVx**] [**-\-version**] [**-\-help**] [**-\-digit-clamp**] [**-\-no-digit-clamp**] …
41 dc(1) is an arbitrary-precision calculator. It uses a stack (reverse Polish
45 If no files are given on the command-line, then dc(1) reads from **stdin** (see
46 the **STDIN** section). Otherwise, those files are processed, and dc(1) will
51 **scale** always set to **10**, they can set **DC_ENV_ARGS** to **-e 10k**, and
52 this dc(1) will always start with a **scale** of **10**.
56 The following are the options that dc(1) accepts.
58 **-C**, **-\-no-digit-clamp**
67 If this and/or the **-c** or **-\-digit-clamp** options are given multiple
72 with the **-h** or **-\-help** options.
74 This is a **non-portable extension**.
76 **-c**, **-\-digit-clamp**
86 If this and/or the **-C** or **-\-no-digit-clamp** options are given
91 with the **-h** or **-\-help** options.
93 This is a **non-portable extension**.
95 **-e** *expr*, **-\-expression**=*expr*
102 If this option is given on the command-line (i.e., not in **DC_ENV_ARGS**,
104 expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
105 as an argument at least once to **-f** or **-\-file**, whether on the
106 command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
107 **-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
108 or equivalent is given, dc(1) will give a fatal error and exit.
110 This is a **non-portable extension**.
112 **-f** *file*, **-\-file**=*file*
118 If this option is given on the command-line (i.e., not in **DC_ENV_ARGS**,
120 expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
121 as an argument at least once to **-f** or **-\-file**. However, if any other
122 **-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
123 **-f-** or equivalent is given, dc(1) will give a fatal error and exit.
125 This is a **non-portable extension**.
127 **-h**, **-\-help**
131 **-I** *ibase*, **-\-ibase**=*ibase*
138 This is a **non-portable extension**.
140 **-i**, **-\-interactive**
144 This is a **non-portable extension**.
146 **-L**, **-\-no-line-length**
152 This is a **non-portable extension**.
154 **-O** *obase*, **-\-obase**=*obase*
161 This is a **non-portable extension**.
163 **-P**, **-\-no-prompt**
167 want a prompt or are not used to having them in dc(1). Most of those users
173 This is a **non-portable extension**.
175 **-R**, **-\-no-read-prompt**
179 do not want a read prompt or are not used to having them in dc(1). Most of
182 lines of dc(1) scripts that prompt for user input.
184 This option does not disable the regular prompt because the read prompt is
191 This is a **non-portable extension**.
193 **-S** *scale*, **-\-scale**=*scale*
200 This is a **non-portable extension**.
202 **-v**, **-V**, **-\-version**
206 **-x** **-\-extended-register**
211 This is a **non-portable extension**.
213 **-z**, **-\-leading-zeroes**
215 : Makes dc(1) print all numbers greater than **-1** and less than **1**, and
218 This is a **non-portable extension**.
220 All long options are **non-portable extensions**.
224 If no files are given on the command-line and no files or expressions are given
225 by the **-f**, **-\-file**, **-e**, or **-\-expression** options, then dc(1)
232 brackets, all brackets must be balanced before dc(1) parses and executes.
236 Any non-error output is written to **stdout**. In addition, if history (see the
240 **Note**: Unlike other dc(1) implementations, this dc(1) will issue a fatal
242 **stdout** is closed, as in **dc <file> >&-**, it will quit with an error. This
243 is done so that dc(1) can report problems when **stdout** is redirected to a
246 If there are scripts that depend on the behavior of other dc(1) implementations,
254 **Note**: Unlike other dc(1) implementations, this dc(1) will issue a fatal
256 **stderr** is closed, as in **dc <file> 2>&-**, it will quit with an error. This
257 is done so that dc(1) can exit with an error code when **stderr** is redirected
260 If there are scripts that depend on the behavior of other dc(1) implementations,
274 The max allowable value for **ibase** can be queried in dc(1) programs with the
287 allowable value for **scale** can be queried in dc(1) programs with the **V**
293 **non-portable extension**.
304 behavior depends on the existence of the **-c**/**-\-digit-clamp** or
305 **-C**/**-\-no-digit-clamp** options (see the **OPTIONS** section), the
308 the **-h**/**-\-help** option.
323 There is one exception to clamping: single-character numbers (i.e., **A**
360 interpreted as an 8-bit ASCII character, making it a byte stream.
364 This is a **non-portable extension**.
383 **-**
402 The first value popped off of the stack must be non-zero.
410 2) Using the result of step 1 to calculate **a-(a/b)\*b** to *scale*
413 The first value popped off of the stack must be non-zero.
422 The first value popped off of the stack must be non-zero.
424 This is a **non-portable extension**.
434 non-zero.
442 The value popped off of the stack must be non-negative.
451 **non-portable extension**.
458 This is a **non-portable extension**.
466 integer and non-zero. The second value popped is used as the exponent and
467 must be an integer and non-negative. The third value popped is the base and
470 This is a **non-portable extension**.
477 This is a **non-portable extension**.
484 This is a **non-portable extension**.
491 This is a **non-portable extension**.
499 This is a **non-portable extension**.
506 This is a **non-portable extension**.
514 This is a **non-portable extension**.
518 : The top two values are popped off of the stack. If they are both non-zero, a
522 This is like the **&&** operator in bc(1), and it is *not* a short-circuit
525 This is a **non-portable extension**.
530 non-zero, a **1** is pushed onto the stack. If both of them are zero, then a
533 This is like the **||** operator in bc(1), and it is *not* a short-circuit
536 This is a **non-portable extension**.
606 which must be non-negative.
626 This is a **non-portable extension**.
632 This is a **non-portable extension**.
638 This is a **non-portable extension**.
644 dc(1) can work with both numbers and strings, and registers (see the
645 **REGISTERS** section) can hold both strings and numbers. dc(1) always knows
673 string; otherwise, push a one-character string where the character is the
678 the original string is used to create the new string as a one-character
681 This is a **non-portable extension**.
703 If either or both of the values are not numbers, dc(1) will raise an error
710 If either or both of the values are not numbers, dc(1) will raise an error
713 This is a **non-portable extension**.
721 If either or both of the values are not numbers, dc(1) will raise an error
728 If either or both of the values are not numbers, dc(1) will raise an error
731 This is a **non-portable extension**.
739 If either or both of the values are not numbers, dc(1) will raise an error
746 If either or both of the values are not numbers, dc(1) will raise an error
749 This is a **non-portable extension**.
757 If either or both of the values are not numbers, dc(1) will raise an error
764 If either or both of the values are not numbers, dc(1) will raise an error
767 This is a **non-portable extension**.
775 If either or both of the values are not numbers, dc(1) will raise an error
782 If either or both of the values are not numbers, dc(1) will raise an error
785 This is a **non-portable extension**.
793 If either or both of the values are not numbers, dc(1) will raise an error
800 If either or both of the values are not numbers, dc(1) will raise an error
803 This is a **non-portable extension**.
814 macro executing, dc(1) exits.
818 : Pops a value from the stack which must be non-negative and is used the
820 of levels to pop is greater than the number of executing macros, dc(1)
827 is exactly as many as is needed to make dc(1) exit with the **Q** command,
828 so the sequence **,Q** will make dc(1) exit.
830 This is a **non-portable extension**.
859 This is a **non-portable extension**.
866 This is a **non-portable extension**.
878 item) when dc(1) starts, dc(1) requires that each register's stack must
879 always have at least one item; dc(1) will give an error and reset otherwise
883 This is a **non-portable extension**.
903 This is a **non-portable extension**.
926 with the **-z** or **-\-leading-zeroes** options (see the **OPTIONS**
927 section), non-zero otherwise.
939 In non-extended register mode, a register name is just the single character that
946 Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
949 If extended register mode is enabled (**-x** or **-\-extended-register**
950 command-line arguments are given), then normal single character registers are
956 **\[a-z\]\[a-z0-9\_\]\*** (like bc(1) identifiers), and it is a parse error if
957 the next non-space characters do not match that regex.
961 When dc(1) encounters an error or a signal that it has a non-default handler
972 Thus, when dc(1) resets, it skips any remaining code waiting to be executed.
979 Most dc(1) implementations use **char** types to calculate the value of **1**
980 decimal digit at a time, but that can be slow. This dc(1) does something
990 In addition, this dc(1) uses an even larger integer for overflow checking. This
996 The following are the limits on dc(1):
1000 : The number of bits in the **long** type in the environment where dc(1) was
1025 : The maximum size of arrays. Set at **SIZE_MAX-1**.
1029 : The maximum **scale**. Set at **DC_OVERFLOW_MAX-1**.
1033 : The maximum length of strings. Set at **DC_OVERFLOW_MAX-1**.
1037 : The maximum length of identifiers. Set at **DC_OVERFLOW_MAX-1**.
1042 after the decimal point. Set at **DC_OVERFLOW_MAX-1**.
1051 : The maximum number of vars/arrays. Set at **SIZE_MAX-1**.
1053 These limits are meant to be effectively non-existent; the limits are so large
1054 (at least on 64-bit machines) that there should not be any point at which they
1060 As **non-portable extensions**, dc(1) recognizes the following environment
1065 : This is another way to give command-line arguments to dc(1). They should be
1066 in the same format as all other command-line arguments. These are always
1068 before arguments and files given on the command-line. This gives the user
1071 functions that the user might want every time dc(1) runs. Another use would
1072 be to use the **-e** option to set **scale** to a value other than **0**.
1076 **"/home/gavin/some dc file.dc"** will be correctly parsed, but the string
1077 **"/home/gavin/some \"dc\" file.dc"** will include the backslashes.
1081 double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
1085 command-line where the parsing is done by the shell.
1090 than **1** and is less than **UINT16_MAX** (**2\^16-1**), dc(1) will output
1094 The special value of **0** will disable line length checking and print
1099 : If dc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
1100 then this environment variable has no effect because dc(1) exits on
1103 However, when dc(1) is in interactive mode, then if this environment
1104 variable exists and contains an integer, a non-zero value makes dc(1) reset
1105 on **SIGINT**, rather than exit, and zero makes dc(1) exit. If this
1106 environment variable exists and is *not* an integer, then dc(1) will exit on
1110 the **-h** or **-\-help** options.
1118 exists and contains an integer, then a non-zero value makes dc(1) use TTY
1119 mode, and zero makes dc(1) not use TTY mode.
1122 the **-h** or **-\-help** options.
1130 exists and contains an integer, a non-zero value makes dc(1) use a prompt,
1131 and zero or a non-integer makes dc(1) not use a prompt. If this environment
1136 override the default, which can be queried with the **-h** or **-\-help**
1141 : If any expressions or expression files are given on the command-line with
1142 **-e**, **-\-expression**, **-f**, or **-\-file**, then if this environment
1143 variable exists and contains an integer, a non-zero value makes dc(1) exit
1145 dc(1) not exit.
1148 the **-h** or **-\-help** options.
1153 integer, a non-zero value makes dc(1) clamp digits that are greater than or
1159 This never applies to single-digit numbers, as per the bc(1) standard (see
1163 the **-h** or **-\-help** options.
1167 dc(1) returns the following exit statuses:
1182 calculating the size of a number, and attempting to use a non-integer where
1211 files, attempting to use files that do not have only ASCII characters (dc(1)
1213 and giving invalid command-line options.
1215 The exit status **4** is special; when a fatal error occurs, dc(1) always exits
1216 and returns **4**, no matter what mode dc(1) is in.
1218 The other statuses will only be returned when dc(1) is not in interactive mode
1219 (see the **INTERACTIVE MODE** section), since dc(1) resets its state (see the
1222 **-i** flag or **-\-interactive** option.
1224 These exit statuses allow dc(1) to be used in shell scripting with error
1225 checking, and its normal behavior can be forced by using the **-i** flag or
1226 **-\-interactive** option.
1230 Like bc(1), dc(1) has an interactive mode and a non-interactive mode.
1232 are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
1235 In interactive mode, dc(1) attempts to recover from errors (see the **RESET**
1237 done for the current input. dc(1) may also reset on **SIGINT** instead of exit,
1244 mode" is considered to be available, and thus, dc(1) can turn on TTY mode,
1249 non-zero integer, dc(1) will turn on TTY mode when **stdin**, **stdout**, and
1251 variable exists but is *not* a non-zero integer, then dc(1) will not turn TTY
1255 setting is used. The default setting can be queried with the **-h** or
1256 **-\-help** options.
1262 ## Command-Line History
1264 Command-line history is only enabled if TTY mode is, i.e., that **stdin**,
1267 do not disable TTY mode. See the **COMMAND LINE HISTORY** section for more
1276 If the environment variable **DC_PROMPT** exists and is a non-zero integer, then
1278 to a TTY and the **-P** and **-\-no-prompt** options were not used. The read
1279 prompt will be turned on under the same conditions, except that the **-R** and
1280 **-\-no-read-prompt** options must also not be used.
1283 with the **DC_TTY_MODE** environment variable, the **-P** and **-\-no-prompt**
1284 options, and the **-R** and **-\-no-read-prompt** options. See the **ENVIRONMENT
1289 Sending a **SIGINT** will cause dc(1) to do one of two things.
1291 If dc(1) is not in interactive mode (see the **INTERACTIVE MODE** section), or
1293 section), or its default, is either not an integer or it is zero, dc(1) will
1296 However, if dc(1) is in interactive mode, and the **DC_SIGINT_RESET** or its
1297 default is an integer and non-zero, then dc(1) will stop executing the current
1300 Note that "current input" can mean one of two things. If dc(1) is processing
1301 input from **stdin** in interactive mode, it will ask for more input. If dc(1)
1306 This means that if a **SIGINT** is sent to dc(1) as it is executing a file, it
1307 can seem as though dc(1) did not respond to the signal since it will immediately
1309 when interacting with dc(1) have function definitions, which are quick to parse.
1314 **SIGTERM** and **SIGQUIT** cause dc(1) to clean up and exit, and it uses the
1316 case, and only when dc(1) is in TTY mode (see the **TTY MODE** section), a
1317 **SIGHUP** will cause dc(1) to clean up and exit.
1321 dc(1) supports interactive command-line editing.
1323 If dc(1) can be in TTY mode (see the **TTY MODE** section), history can be
1324 enabled. This means that command-line history can only be enabled when
1334 This dc(1) ships with support for adding error messages for different locales
1343 The dc(1) utility operators and some behavior are compliant with the operators
1344 in the IEEE Std 1003.1-2017 (“POSIX.1-2017”) bc(1) specification at