1<!--- 2 3SPDX-License-Identifier: BSD-2-Clause 4 5Copyright (c) 2018-2021 Gavin D. Howard and contributors. 6 7Redistribution and use in source and binary forms, with or without 8modification, are permitted provided that the following conditions are met: 9 10* Redistributions of source code must retain the above copyright notice, this 11 list of conditions and the following disclaimer. 12 13* Redistributions in binary form must reproduce the above copyright notice, 14 this list of conditions and the following disclaimer in the documentation 15 and/or other materials provided with the distribution. 16 17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27POSSIBILITY OF SUCH DAMAGE. 28 29--> 30 31# Name 32 33dc - arbitrary-precision decimal reverse-Polish notation calculator 34 35# SYNOPSIS 36 37**dc** [**-hiPRvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-no-read-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...] 38 39# DESCRIPTION 40 41dc(1) is an arbitrary-precision calculator. It uses a stack (reverse Polish 42notation) to store numbers and results of computations. Arithmetic operations 43pop arguments off of the stack and push the results. 44 45If no files are given on the command-line, then dc(1) reads from **stdin** (see 46the **STDIN** section). Otherwise, those files are processed, and dc(1) will 47then exit. 48 49If a user wants to set up a standard environment, they can use **DC_ENV_ARGS** 50(see the **ENVIRONMENT VARIABLES** section). For example, if a user wants the 51**scale** always set to **10**, they can set **DC_ENV_ARGS** to **-e 10k**, and 52this dc(1) will always start with a **scale** of **10**. 53 54# OPTIONS 55 56The following are the options that dc(1) accepts. 57 58**-h**, **-\-help** 59 60: Prints a usage message and quits. 61 62**-v**, **-V**, **-\-version** 63 64: Print the version information (copyright header) and exit. 65 66**-i**, **-\-interactive** 67 68: Forces interactive mode. (See the **INTERACTIVE MODE** section.) 69 70 This is a **non-portable extension**. 71 72**-P**, **-\-no-prompt** 73 74: Disables the prompt in TTY mode. (The prompt is only enabled in TTY mode. 75 See the **TTY MODE** section.) This is mostly for those users that do not 76 want a prompt or are not used to having them in dc(1). Most of those users 77 would want to put this option in **DC_ENV_ARGS**. 78 79 These options override the **DC_PROMPT** and **DC_TTY_MODE** environment 80 variables (see the **ENVIRONMENT VARIABLES** section). 81 82 This is a **non-portable extension**. 83 84**-R**, **-\-no-read-prompt** 85 86: Disables the read prompt in TTY mode. (The read prompt is only enabled in 87 TTY mode. See the **TTY MODE** section.) This is mostly for those users that 88 do not want a read prompt or are not used to having them in dc(1). Most of 89 those users would want to put this option in **BC_ENV_ARGS** (see the 90 **ENVIRONMENT VARIABLES** section). This option is also useful in hash bang 91 lines of dc(1) scripts that prompt for user input. 92 93 This option does not disable the regular prompt because the read prompt is 94 only used when the **?** command is used. 95 96 These options *do* override the **DC_PROMPT** and **DC_TTY_MODE** 97 environment variables (see the **ENVIRONMENT VARIABLES** section), but only 98 for the read prompt. 99 100 This is a **non-portable extension**. 101 102**-x** **-\-extended-register** 103 104: Enables extended register mode. See the *Extended Register Mode* subsection 105 of the **REGISTERS** section for more information. 106 107 This is a **non-portable extension**. 108 109**-e** *expr*, **-\-expression**=*expr* 110 111: Evaluates *expr*. If multiple expressions are given, they are evaluated in 112 order. If files are given as well (see below), the expressions and files are 113 evaluated in the order given. This means that if a file is given before an 114 expression, the file is read in and evaluated first. 115 116 If this option is given on the command-line (i.e., not in **DC_ENV_ARGS**, 117 see the **ENVIRONMENT VARIABLES** section), then after processing all 118 expressions and files, dc(1) will exit, unless **-** (**stdin**) was given 119 as an argument at least once to **-f** or **-\-file**, whether on the 120 command-line or in **DC_ENV_ARGS**. However, if any other **-e**, 121 **-\-expression**, **-f**, or **-\-file** arguments are given after **-f-** 122 or equivalent is given, dc(1) will give a fatal error and exit. 123 124 This is a **non-portable extension**. 125 126**-f** *file*, **-\-file**=*file* 127 128: Reads in *file* and evaluates it, line by line, as though it were read 129 through **stdin**. If expressions are also given (see above), the 130 expressions are evaluated in the order given. 131 132 If this option is given on the command-line (i.e., not in **DC_ENV_ARGS**, 133 see the **ENVIRONMENT VARIABLES** section), then after processing all 134 expressions and files, dc(1) will exit, unless **-** (**stdin**) was given 135 as an argument at least once to **-f** or **-\-file**. However, if any other 136 **-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after 137 **-f-** or equivalent is given, dc(1) will give a fatal error and exit. 138 139 This is a **non-portable extension**. 140 141All long options are **non-portable extensions**. 142 143# STDIN 144 145If no files are given on the command-line and no files or expressions are given 146by the **-f**, **-\-file**, **-e**, or **-\-expression** options, then dc(1) 147read from **stdin**. 148 149However, there is a caveat to this. 150 151First, **stdin** is evaluated a line at a time. The only exception to this is if 152a string has been finished, but not ended. This means that, except for escaped 153brackets, all brackets must be balanced before dc(1) parses and executes. 154 155# STDOUT 156 157Any non-error output is written to **stdout**. In addition, if history (see the 158**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled, 159both are output to **stdout**. 160 161**Note**: Unlike other dc(1) implementations, this dc(1) will issue a fatal 162error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if 163**stdout** is closed, as in **dc <file> >&-**, it will quit with an error. This 164is done so that dc(1) can report problems when **stdout** is redirected to a 165file. 166 167If there are scripts that depend on the behavior of other dc(1) implementations, 168it is recommended that those scripts be changed to redirect **stdout** to 169**/dev/null**. 170 171# STDERR 172 173Any error output is written to **stderr**. 174 175**Note**: Unlike other dc(1) implementations, this dc(1) will issue a fatal 176error (see the **EXIT STATUS** section) if it cannot write to **stderr**, so if 177**stderr** is closed, as in **dc <file> 2>&-**, it will quit with an error. This 178is done so that dc(1) can exit with an error code when **stderr** is redirected 179to a file. 180 181If there are scripts that depend on the behavior of other dc(1) implementations, 182it is recommended that those scripts be changed to redirect **stderr** to 183**/dev/null**. 184 185# SYNTAX 186 187Each item in the input source code, either a number (see the **NUMBERS** 188section) or a command (see the **COMMANDS** section), is processed and executed, 189in order. Input is processed immediately when entered. 190 191**ibase** is a register (see the **REGISTERS** section) that determines how to 192interpret constant numbers. It is the "input" base, or the number base used for 193interpreting input numbers. **ibase** is initially **10**. The max allowable 194value for **ibase** is **16**. The min allowable value for **ibase** is **2**. 195The max allowable value for **ibase** can be queried in dc(1) programs with the 196**T** command. 197 198**obase** is a register (see the **REGISTERS** section) that determines how to 199output results. It is the "output" base, or the number base used for outputting 200numbers. **obase** is initially **10**. The max allowable value for **obase** is 201**DC_BASE_MAX** and can be queried with the **U** command. The min allowable 202{{ A H N HN }} 203value for **obase** is **0**. If **obase** is **0**, values are output in 204scientific notation, and if **obase** is **1**, values are output in engineering 205notation. Otherwise, values are output in the specified base. 206 207Outputting in scientific and engineering notations are **non-portable 208extensions**. 209{{ end }} 210{{ E EH EN EHN }} 211value for **obase** is **2**. Values are output in the specified base. 212{{ end }} 213 214The *scale* of an expression is the number of digits in the result of the 215expression right of the decimal point, and **scale** is a register (see the 216**REGISTERS** section) that sets the precision of any operations (with 217exceptions). **scale** is initially **0**. **scale** cannot be negative. The max 218allowable value for **scale** can be queried in dc(1) programs with the **V** 219command. 220 221{{ A H N HN }} 222**seed** is a register containing the current seed for the pseudo-random number 223generator. If the current value of **seed** is queried and stored, then if it is 224assigned to **seed** later, the pseudo-random number generator is guaranteed to 225produce the same sequence of pseudo-random numbers that were generated after the 226value of **seed** was first queried. 227 228Multiple values assigned to **seed** can produce the same sequence of 229pseudo-random numbers. Likewise, when a value is assigned to **seed**, it is not 230guaranteed that querying **seed** immediately after will return the same value. 231In addition, the value of **seed** will change after any call to the **'** 232command or the **"** command that does not get receive a value of **0** or 233**1**. The maximum integer returned by the **'** command can be queried with the 234**W** command. 235 236**Note**: The values returned by the pseudo-random number generator with the 237**'** and **"** commands are guaranteed to **NOT** be cryptographically secure. 238This is a consequence of using a seeded pseudo-random number generator. However, 239they *are* guaranteed to be reproducible with identical **seed** values. This 240means that the pseudo-random values from dc(1) should only be used where a 241reproducible stream of pseudo-random numbers is *ESSENTIAL*. In any other case, 242use a non-seeded pseudo-random number generator. 243 244The pseudo-random number generator, **seed**, and all associated operations are 245**non-portable extensions**. 246{{ end }} 247 248## Comments 249 250Comments go from **#** until, and not including, the next newline. This is a 251**non-portable extension**. 252 253# NUMBERS 254 255Numbers are strings made up of digits, uppercase letters up to **F**, and at 256most **1** period for a radix. Numbers can have up to **DC_NUM_MAX** digits. 257Uppercase letters are equal to **9** + their position in the alphabet (i.e., 258**A** equals **10**, or **9+1**). If a digit or letter makes no sense with the 259current value of **ibase**, they are set to the value of the highest valid digit 260in **ibase**. 261 262Single-character numbers (i.e., **A** alone) take the value that they would have 263if they were valid digits, regardless of the value of **ibase**. This means that 264**A** alone always equals decimal **10** and **F** alone always equals decimal 265**15**. 266 267{{ A H N HN }} 268In addition, dc(1) accepts numbers in scientific notation. These have the form 269**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be 270an integer. An example is **1.89237e9**, which is equal to **1892370000**. 271Negative exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**. 272 273**WARNING**: Both the number and the exponent in scientific notation are 274interpreted according to the current **ibase**, but the number is still 275multiplied by **10\^exponent** regardless of the current **ibase**. For example, 276if **ibase** is **16** and dc(1) is given the number string **FFeA**, the 277resulting decimal number will be **2550000000000**, and if dc(1) is given the 278number string **10e_4**, the resulting decimal number will be **0.0016**. 279 280Accepting input as scientific notation is a **non-portable extension**. 281{{ end }} 282 283# COMMANDS 284 285The valid commands are listed below. 286 287## Printing 288 289These commands are used for printing. 290 291{{ A H N HN }} 292Note that both scientific notation and engineering notation are available for 293printing numbers. Scientific notation is activated by assigning **0** to 294**obase** using **0o**, and engineering notation is activated by assigning **1** 295to **obase** using **1o**. To deactivate them, just assign a different value to 296**obase**. 297 298Printing numbers in scientific notation and/or engineering notation is a 299**non-portable extension**. 300{{ end }} 301 302**p** 303 304: Prints the value on top of the stack, whether number or string, and prints a 305 newline after. 306 307 This does not alter the stack. 308 309**n** 310 311: Prints the value on top of the stack, whether number or string, and pops it 312 off of the stack. 313 314**P** 315 316: Pops a value off the stack. 317 318 If the value is a number, it is truncated and the absolute value of the 319 result is printed as though **obase** is **256** and each digit is 320 interpreted as an 8-bit ASCII character, making it a byte stream. 321 322 If the value is a string, it is printed without a trailing newline. 323 324 This is a **non-portable extension**. 325 326**f** 327 328: Prints the entire contents of the stack, in order from newest to oldest, 329 without altering anything. 330 331 Users should use this command when they get lost. 332 333## Arithmetic 334 335These are the commands used for arithmetic. 336 337**+** 338 339: The top two values are popped off the stack, added, and the result is pushed 340 onto the stack. The *scale* of the result is equal to the max *scale* of 341 both operands. 342 343**-** 344 345: The top two values are popped off the stack, subtracted, and the result is 346 pushed onto the stack. The *scale* of the result is equal to the max 347 *scale* of both operands. 348 349**\*** 350 351: The top two values are popped off the stack, multiplied, and the result is 352 pushed onto the stack. If **a** is the *scale* of the first expression and 353 **b** is the *scale* of the second expression, the *scale* of the result 354 is equal to **min(a+b,max(scale,a,b))** where **min()** and **max()** return 355 the obvious values. 356 357**/** 358 359: The top two values are popped off the stack, divided, and the result is 360 pushed onto the stack. The *scale* of the result is equal to **scale**. 361 362 The first value popped off of the stack must be non-zero. 363 364**%** 365 366: The top two values are popped off the stack, remaindered, and the result is 367 pushed onto the stack. 368 369 Remaindering is equivalent to 1) Computing **a/b** to current **scale**, and 370 2) Using the result of step 1 to calculate **a-(a/b)\*b** to *scale* 371 **max(scale+scale(b),scale(a))**. 372 373 The first value popped off of the stack must be non-zero. 374 375**~** 376 377: The top two values are popped off the stack, divided and remaindered, and 378 the results (divided first, remainder second) are pushed onto the stack. 379 This is equivalent to **x y / x y %** except that **x** and **y** are only 380 evaluated once. 381 382 The first value popped off of the stack must be non-zero. 383 384 This is a **non-portable extension**. 385 386**\^** 387 388: The top two values are popped off the stack, the second is raised to the 389 power of the first, and the result is pushed onto the stack. The *scale* of 390 the result is equal to **scale**. 391 392 The first value popped off of the stack must be an integer, and if that 393 value is negative, the second value popped off of the stack must be 394 non-zero. 395 396**v** 397 398: The top value is popped off the stack, its square root is computed, and the 399 result is pushed onto the stack. The *scale* of the result is equal to 400 **scale**. 401 402 The value popped off of the stack must be non-negative. 403 404**\_** 405 406: If this command *immediately* precedes a number (i.e., no spaces or other 407 commands), then that number is input as a negative number. 408 409 Otherwise, the top value on the stack is popped and copied, and the copy is 410 negated and pushed onto the stack. This behavior without a number is a 411 **non-portable extension**. 412 413**b** 414 415: The top value is popped off the stack, and if it is zero, it is pushed back 416 onto the stack. Otherwise, its absolute value is pushed onto the stack. 417 418 This is a **non-portable extension**. 419 420**|** 421 422: The top three values are popped off the stack, a modular exponentiation is 423 computed, and the result is pushed onto the stack. 424 425 The first value popped is used as the reduction modulus and must be an 426 integer and non-zero. The second value popped is used as the exponent and 427 must be an integer and non-negative. The third value popped is the base and 428 must be an integer. 429 430 This is a **non-portable extension**. 431 432{{ A H N HN }} 433**\$** 434 435: The top value is popped off the stack and copied, and the copy is truncated 436 and pushed onto the stack. 437 438 This is a **non-portable extension**. 439 440**\@** 441 442: The top two values are popped off the stack, and the precision of the second 443 is set to the value of the first, whether by truncation or extension. 444 445 The first value popped off of the stack must be an integer and non-negative. 446 447 This is a **non-portable extension**. 448 449**H** 450 451: The top two values are popped off the stack, and the second is shifted left 452 (radix shifted right) to the value of the first. 453 454 The first value popped off of the stack must be an integer and non-negative. 455 456 This is a **non-portable extension**. 457 458**h** 459 460: The top two values are popped off the stack, and the second is shifted right 461 (radix shifted left) to the value of the first. 462 463 The first value popped off of the stack must be an integer and non-negative. 464 465 This is a **non-portable extension**. 466{{ end }} 467 468**G** 469 470: The top two values are popped off of the stack, they are compared, and a 471 **1** is pushed if they are equal, or **0** otherwise. 472 473 This is a **non-portable extension**. 474 475**N** 476 477: The top value is popped off of the stack, and if it a **0**, a **1** is 478 pushed; otherwise, a **0** is pushed. 479 480 This is a **non-portable extension**. 481 482**(** 483 484: The top two values are popped off of the stack, they are compared, and a 485 **1** is pushed if the first is less than the second, or **0** otherwise. 486 487 This is a **non-portable extension**. 488 489**{** 490 491: The top two values are popped off of the stack, they are compared, and a 492 **1** is pushed if the first is less than or equal to the second, or **0** 493 otherwise. 494 495 This is a **non-portable extension**. 496 497**)** 498 499: The top two values are popped off of the stack, they are compared, and a 500 **1** is pushed if the first is greater than the second, or **0** otherwise. 501 502 This is a **non-portable extension**. 503 504**}** 505 506: The top two values are popped off of the stack, they are compared, and a 507 **1** is pushed if the first is greater than or equal to the second, or 508 **0** otherwise. 509 510 This is a **non-portable extension**. 511 512**M** 513 514: The top two values are popped off of the stack. If they are both non-zero, a 515 **1** is pushed onto the stack. If either of them is zero, or both of them 516 are, then a **0** is pushed onto the stack. 517 518 This is like the **&&** operator in bc(1), and it is *not* a short-circuit 519 operator. 520 521 This is a **non-portable extension**. 522 523**m** 524 525: The top two values are popped off of the stack. If at least one of them is 526 non-zero, a **1** is pushed onto the stack. If both of them are zero, then a 527 **0** is pushed onto the stack. 528 529 This is like the **||** operator in bc(1), and it is *not* a short-circuit 530 operator. 531 532 This is a **non-portable extension**. 533 534{{ A H N HN }} 535## Pseudo-Random Number Generator 536 537dc(1) has a built-in pseudo-random number generator. These commands query the 538pseudo-random number generator. (See Parameters for more information about the 539**seed** value that controls the pseudo-random number generator.) 540 541The pseudo-random number generator is guaranteed to **NOT** be 542cryptographically secure. 543 544**'** 545 546: Generates an integer between 0 and **DC_RAND_MAX**, inclusive (see the 547 **LIMITS** section). 548 549 The generated integer is made as unbiased as possible, subject to the 550 limitations of the pseudo-random number generator. 551 552 This is a **non-portable extension**. 553 554**"** 555 556: Pops a value off of the stack, which is used as an **exclusive** upper bound 557 on the integer that will be generated. If the bound is negative or is a 558 non-integer, an error is raised, and dc(1) resets (see the **RESET** 559 section) while **seed** remains unchanged. If the bound is larger than 560 **DC_RAND_MAX**, the higher bound is honored by generating several 561 pseudo-random integers, multiplying them by appropriate powers of 562 **DC_RAND_MAX+1**, and adding them together. Thus, the size of integer that 563 can be generated with this command is unbounded. Using this command will 564 change the value of **seed**, unless the operand is **0** or **1**. In that 565 case, **0** is pushed onto the stack, and **seed** is *not* changed. 566 567 The generated integer is made as unbiased as possible, subject to the 568 limitations of the pseudo-random number generator. 569 570 This is a **non-portable extension**. 571{{ end }} 572 573## Stack Control 574 575These commands control the stack. 576 577**c** 578 579: Removes all items from ("clears") the stack. 580 581**d** 582 583: Copies the item on top of the stack ("duplicates") and pushes the copy onto 584 the stack. 585 586**r** 587 588: Swaps ("reverses") the two top items on the stack. 589 590**R** 591 592: Pops ("removes") the top value from the stack. 593 594## Register Control 595 596These commands control registers (see the **REGISTERS** section). 597 598**s**_r_ 599 600: Pops the value off the top of the stack and stores it into register *r*. 601 602**l**_r_ 603 604: Copies the value in register *r* and pushes it onto the stack. This does not 605 alter the contents of *r*. 606 607**S**_r_ 608 609: Pops the value off the top of the (main) stack and pushes it onto the stack 610 of register *r*. The previous value of the register becomes inaccessible. 611 612**L**_r_ 613 614: Pops the value off the top of the stack for register *r* and push it onto 615 the main stack. The previous value in the stack for register *r*, if any, is 616 now accessible via the **l**_r_ command. 617 618## Parameters 619 620{{ A H N HN }} 621These commands control the values of **ibase**, **obase**, **scale**, and 622**seed**. Also see the **SYNTAX** section. 623{{ end }} 624{{ E EH EN EHN }} 625These commands control the values of **ibase**, **obase**, and **scale**. Also 626see the **SYNTAX** section. 627{{ end }} 628 629**i** 630 631: Pops the value off of the top of the stack and uses it to set **ibase**, 632 which must be between **2** and **16**, inclusive. 633 634 If the value on top of the stack has any *scale*, the *scale* is ignored. 635 636**o** 637 638: Pops the value off of the top of the stack and uses it to set **obase**, 639{{ A H N HN }} 640 which must be between **0** and **DC_BASE_MAX**, inclusive (see the 641 **LIMITS** section and the **NUMBERS** section). 642{{ end }} 643{{ E EH EN EHN }} 644 which must be between **2** and **DC_BASE_MAX**, inclusive (see the 645 **LIMITS** section). 646{{ end }} 647 648 If the value on top of the stack has any *scale*, the *scale* is ignored. 649 650**k** 651 652: Pops the value off of the top of the stack and uses it to set **scale**, 653 which must be non-negative. 654 655 If the value on top of the stack has any *scale*, the *scale* is ignored. 656 657{{ A H N HN }} 658**j** 659 660: Pops the value off of the top of the stack and uses it to set **seed**. The 661 meaning of **seed** is dependent on the current pseudo-random number 662 generator but is guaranteed to not change except for new major versions. 663 664 The *scale* and sign of the value may be significant. 665 666 If a previously used **seed** value is used again, the pseudo-random number 667 generator is guaranteed to produce the same sequence of pseudo-random 668 numbers as it did when the **seed** value was previously used. 669 670 The exact value assigned to **seed** is not guaranteed to be returned if the 671 **J** command is used. However, if **seed** *does* return a different value, 672 both values, when assigned to **seed**, are guaranteed to produce the same 673 sequence of pseudo-random numbers. This means that certain values assigned 674 to **seed** will not produce unique sequences of pseudo-random numbers. 675 676 There is no limit to the length (number of significant decimal digits) or 677 *scale* of the value that can be assigned to **seed**. 678 679 This is a **non-portable extension**. 680{{ end }} 681 682**I** 683 684: Pushes the current value of **ibase** onto the main stack. 685 686**O** 687 688: Pushes the current value of **obase** onto the main stack. 689 690**K** 691 692: Pushes the current value of **scale** onto the main stack. 693 694{{ A H N HN }} 695**J** 696 697: Pushes the current value of **seed** onto the main stack. 698 699 This is a **non-portable extension**. 700{{ end }} 701 702**T** 703 704: Pushes the maximum allowable value of **ibase** onto the main stack. 705 706 This is a **non-portable extension**. 707 708**U** 709 710: Pushes the maximum allowable value of **obase** onto the main stack. 711 712 This is a **non-portable extension**. 713 714**V** 715 716: Pushes the maximum allowable value of **scale** onto the main stack. 717 718 This is a **non-portable extension**. 719 720{{ A H N HN }} 721**W** 722 723: Pushes the maximum (inclusive) integer that can be generated with the **'** 724 pseudo-random number generator command. 725 726 This is a **non-portable extension**. 727{{ end }} 728 729## Strings 730 731The following commands control strings. 732 733dc(1) can work with both numbers and strings, and registers (see the 734**REGISTERS** section) can hold both strings and numbers. dc(1) always knows 735whether the contents of a register are a string or a number. 736 737While arithmetic operations have to have numbers, and will print an error if 738given a string, other commands accept strings. 739 740Strings can also be executed as macros. For example, if the string **[1pR]** is 741executed as a macro, then the code **1pR** is executed, meaning that the **1** 742will be printed with a newline after and then popped from the stack. 743 744**\[**_characters_**\]** 745 746: Makes a string containing *characters* and pushes it onto the stack. 747 748 If there are brackets (**\[** and **\]**) in the string, then they must be 749 balanced. Unbalanced brackets can be escaped using a backslash (**\\**) 750 character. 751 752 If there is a backslash character in the string, the character after it 753 (even another backslash) is put into the string verbatim, but the (first) 754 backslash is not. 755 756**a** 757 758: The value on top of the stack is popped. 759 760 If it is a number, it is truncated and its absolute value is taken. The 761 result mod **256** is calculated. If that result is **0**, push an empty 762 string; otherwise, push a one-character string where the character is the 763 result of the mod interpreted as an ASCII character. 764 765 If it is a string, then a new string is made. If the original string is 766 empty, the new string is empty. If it is not, then the first character of 767 the original string is used to create the new string as a one-character 768 string. The new string is then pushed onto the stack. 769 770 This is a **non-portable extension**. 771 772**x** 773 774: Pops a value off of the top of the stack. 775 776 If it is a number, it is pushed back onto the stack. 777 778 If it is a string, it is executed as a macro. 779 780 This behavior is the norm whenever a macro is executed, whether by this 781 command or by the conditional execution commands below. 782 783**\>**_r_ 784 785: Pops two values off of the stack that must be numbers and compares them. If 786 the first value is greater than the second, then the contents of register 787 *r* are executed. 788 789 For example, **0 1>a** will execute the contents of register **a**, and 790 **1 0>a** will not. 791 792 If either or both of the values are not numbers, dc(1) will raise an error 793 and reset (see the **RESET** section). 794 795**>**_r_**e**_s_ 796 797: Like the above, but will execute register *s* if the comparison fails. 798 799 If either or both of the values are not numbers, dc(1) will raise an error 800 and reset (see the **RESET** section). 801 802 This is a **non-portable extension**. 803 804**!\>**_r_ 805 806: Pops two values off of the stack that must be numbers and compares them. If 807 the first value is not greater than the second (less than or equal to), then 808 the contents of register *r* are executed. 809 810 If either or both of the values are not numbers, dc(1) will raise an error 811 and reset (see the **RESET** section). 812 813**!\>**_r_**e**_s_ 814 815: Like the above, but will execute register *s* if the comparison fails. 816 817 If either or both of the values are not numbers, dc(1) will raise an error 818 and reset (see the **RESET** section). 819 820 This is a **non-portable extension**. 821 822**\<**_r_ 823 824: Pops two values off of the stack that must be numbers and compares them. If 825 the first value is less than the second, then the contents of register *r* 826 are executed. 827 828 If either or both of the values are not numbers, dc(1) will raise an error 829 and reset (see the **RESET** section). 830 831**\<**_r_**e**_s_ 832 833: Like the above, but will execute register *s* if the comparison fails. 834 835 If either or both of the values are not numbers, dc(1) will raise an error 836 and reset (see the **RESET** section). 837 838 This is a **non-portable extension**. 839 840**!\<**_r_ 841 842: Pops two values off of the stack that must be numbers and compares them. If 843 the first value is not less than the second (greater than or equal to), then 844 the contents of register *r* are executed. 845 846 If either or both of the values are not numbers, dc(1) will raise an error 847 and reset (see the **RESET** section). 848 849**!\<**_r_**e**_s_ 850 851: Like the above, but will execute register *s* if the comparison fails. 852 853 If either or both of the values are not numbers, dc(1) will raise an error 854 and reset (see the **RESET** section). 855 856 This is a **non-portable extension**. 857 858**=**_r_ 859 860: Pops two values off of the stack that must be numbers and compares them. If 861 the first value is equal to the second, then the contents of register *r* 862 are executed. 863 864 If either or both of the values are not numbers, dc(1) will raise an error 865 and reset (see the **RESET** section). 866 867**=**_r_**e**_s_ 868 869: Like the above, but will execute register *s* if the comparison fails. 870 871 If either or both of the values are not numbers, dc(1) will raise an error 872 and reset (see the **RESET** section). 873 874 This is a **non-portable extension**. 875 876**!=**_r_ 877 878: Pops two values off of the stack that must be numbers and compares them. If 879 the first value is not equal to the second, then the contents of register 880 *r* are executed. 881 882 If either or both of the values are not numbers, dc(1) will raise an error 883 and reset (see the **RESET** section). 884 885**!=**_r_**e**_s_ 886 887: Like the above, but will execute register *s* if the comparison fails. 888 889 If either or both of the values are not numbers, dc(1) will raise an error 890 and reset (see the **RESET** section). 891 892 This is a **non-portable extension**. 893 894**?** 895 896: Reads a line from the **stdin** and executes it. This is to allow macros to 897 request input from users. 898 899**q** 900 901: During execution of a macro, this exits the execution of that macro and the 902 execution of the macro that executed it. If there are no macros, or only one 903 macro executing, dc(1) exits. 904 905**Q** 906 907: Pops a value from the stack which must be non-negative and is used the 908 number of macro executions to pop off of the execution stack. If the number 909 of levels to pop is greater than the number of executing macros, dc(1) 910 exits. 911 912**,** 913 914: Pushes the depth of the execution stack onto the stack. The execution stack 915 is the stack of string executions. The number that is pushed onto the stack 916 is exactly as many as is needed to make dc(1) exit with the **Q** command, 917 so the sequence **,Q** will make dc(1) exit. 918 919## Status 920 921These commands query status of the stack or its top value. 922 923**Z** 924 925: Pops a value off of the stack. 926 927 If it is a number, calculates the number of significant decimal digits it 928 has and pushes the result. It will push **1** if the argument is **0** with 929 no decimal places. 930 931 If it is a string, pushes the number of characters the string has. 932 933**X** 934 935: Pops a value off of the stack. 936 937 If it is a number, pushes the *scale* of the value onto the stack. 938 939 If it is a string, pushes **0**. 940 941**z** 942 943: Pushes the current depth of the stack (before execution of this command) 944 onto the stack. 945 946**y**_r_ 947 948: Pushes the current stack depth of the register *r* onto the main stack. 949 950 Because each register has a depth of **1** (with the value **0** in the top 951 item) when dc(1) starts, dc(1) requires that each register's stack must 952 always have at least one item; dc(1) will give an error and reset otherwise 953 (see the **RESET** section). This means that this command will never push 954 **0**. 955 956 This is a **non-portable extension**. 957 958## Arrays 959 960These commands manipulate arrays. 961 962**:**_r_ 963 964: Pops the top two values off of the stack. The second value will be stored in 965 the array *r* (see the **REGISTERS** section), indexed by the first value. 966 967**;**_r_ 968 969: Pops the value on top of the stack and uses it as an index into the array 970 *r*. The selected value is then pushed onto the stack. 971 972**Y**_r_ 973 974: Pushes the length of the array *r* onto the stack. 975 976 This is a **non-portable extension**. 977 978# REGISTERS 979 980Registers are names that can store strings, numbers, and arrays. (Number/string 981registers do not interfere with array registers.) 982 983Each register is also its own stack, so the current register value is the top of 984the stack for the register. All registers, when first referenced, have one value 985(**0**) in their stack, and it is a runtime error to attempt to pop that item 986off of the register stack. 987 988In non-extended register mode, a register name is just the single character that 989follows any command that needs a register name. The only exceptions are: a 990newline (**'\\n'**) and a left bracket (**'['**); it is a parse error for a 991newline or a left bracket to be used as a register name. 992 993## Extended Register Mode 994 995Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited 996amounts of registers, if extended register mode is enabled. 997 998If extended register mode is enabled (**-x** or **-\-extended-register** 999command-line arguments are given), then normal single character registers are 1000used *unless* the character immediately following a command that needs a 1001register name is a space (according to **isspace()**) and not a newline 1002(**'\\n'**). 1003 1004In that case, the register name is found according to the regex 1005**\[a-z\]\[a-z0-9\_\]\*** (like bc(1) identifiers), and it is a parse error if 1006the next non-space characters do not match that regex. 1007 1008# RESET 1009 1010When dc(1) encounters an error or a signal that it has a non-default handler 1011for, it resets. This means that several things happen. 1012 1013First, any macros that are executing are stopped and popped off the stack. 1014The behavior is not unlike that of exceptions in programming languages. Then 1015the execution point is set so that any code waiting to execute (after all 1016macros returned) is skipped. 1017 1018Thus, when dc(1) resets, it skips any remaining code waiting to be executed. 1019Then, if it is interactive mode, and the error was not a fatal error (see the 1020**EXIT STATUS** section), it asks for more input; otherwise, it exits with the 1021appropriate return code. 1022 1023# PERFORMANCE 1024 1025Most dc(1) implementations use **char** types to calculate the value of **1** 1026decimal digit at a time, but that can be slow. This dc(1) does something 1027different. 1028 1029It uses large integers to calculate more than **1** decimal digit at a time. If 1030built in a environment where **DC_LONG_BIT** (see the **LIMITS** section) is 1031**64**, then each integer has **9** decimal digits. If built in an environment 1032where **DC_LONG_BIT** is **32** then each integer has **4** decimal digits. This 1033value (the number of decimal digits per large integer) is called 1034**DC_BASE_DIGS**. 1035 1036In addition, this dc(1) uses an even larger integer for overflow checking. This 1037integer type depends on the value of **DC_LONG_BIT**, but is always at least 1038twice as large as the integer type used to store digits. 1039 1040# LIMITS 1041 1042The following are the limits on dc(1): 1043 1044**DC_LONG_BIT** 1045 1046: The number of bits in the **long** type in the environment where dc(1) was 1047 built. This determines how many decimal digits can be stored in a single 1048 large integer (see the **PERFORMANCE** section). 1049 1050**DC_BASE_DIGS** 1051 1052: The number of decimal digits per large integer (see the **PERFORMANCE** 1053 section). Depends on **DC_LONG_BIT**. 1054 1055**DC_BASE_POW** 1056 1057: The max decimal number that each large integer can store (see 1058 **DC_BASE_DIGS**) plus **1**. Depends on **DC_BASE_DIGS**. 1059 1060**DC_OVERFLOW_MAX** 1061 1062: The max number that the overflow type (see the **PERFORMANCE** section) can 1063 hold. Depends on **DC_LONG_BIT**. 1064 1065**DC_BASE_MAX** 1066 1067: The maximum output base. Set at **DC_BASE_POW**. 1068 1069**DC_DIM_MAX** 1070 1071: The maximum size of arrays. Set at **SIZE_MAX-1**. 1072 1073**DC_SCALE_MAX** 1074 1075: The maximum **scale**. Set at **DC_OVERFLOW_MAX-1**. 1076 1077**DC_STRING_MAX** 1078 1079: The maximum length of strings. Set at **DC_OVERFLOW_MAX-1**. 1080 1081**DC_NAME_MAX** 1082 1083: The maximum length of identifiers. Set at **DC_OVERFLOW_MAX-1**. 1084 1085**DC_NUM_MAX** 1086 1087: The maximum length of a number (in decimal digits), which includes digits 1088 after the decimal point. Set at **DC_OVERFLOW_MAX-1**. 1089 1090{{ A H N HN }} 1091**DC_RAND_MAX** 1092 1093: The maximum integer (inclusive) returned by the **'** command, if dc(1). Set 1094 at **2\^DC_LONG_BIT-1**. 1095{{ end }} 1096 1097Exponent 1098 1099: The maximum allowable exponent (positive or negative). Set at 1100 **DC_OVERFLOW_MAX**. 1101 1102Number of vars 1103 1104: The maximum number of vars/arrays. Set at **SIZE_MAX-1**. 1105 1106These limits are meant to be effectively non-existent; the limits are so large 1107(at least on 64-bit machines) that there should not be any point at which they 1108become a problem. In fact, memory should be exhausted before these limits should 1109be hit. 1110 1111# ENVIRONMENT VARIABLES 1112 1113dc(1) recognizes the following environment variables: 1114 1115**DC_ENV_ARGS** 1116 1117: This is another way to give command-line arguments to dc(1). They should be 1118 in the same format as all other command-line arguments. These are always 1119 processed first, so any files given in **DC_ENV_ARGS** will be processed 1120 before arguments and files given on the command-line. This gives the user 1121 the ability to set up "standard" options and files to be used at every 1122 invocation. The most useful thing for such files to contain would be useful 1123 functions that the user might want every time dc(1) runs. Another use would 1124 be to use the **-e** option to set **scale** to a value other than **0**. 1125 1126 The code that parses **DC_ENV_ARGS** will correctly handle quoted arguments, 1127 but it does not understand escape sequences. For example, the string 1128 **"/home/gavin/some dc file.dc"** will be correctly parsed, but the string 1129 **"/home/gavin/some \"dc\" file.dc"** will include the backslashes. 1130 1131 The quote parsing will handle either kind of quotes, **'** or **"**. Thus, 1132 if you have a file with any number of single quotes in the name, you can use 1133 double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice 1134 versa if you have a file with double quotes. However, handling a file with 1135 both kinds of quotes in **DC_ENV_ARGS** is not supported due to the 1136 complexity of the parsing, though such files are still supported on the 1137 command-line where the parsing is done by the shell. 1138 1139**DC_LINE_LENGTH** 1140 1141: If this environment variable exists and contains an integer that is greater 1142 than **1** and is less than **UINT16_MAX** (**2\^16-1**), dc(1) will output 1143 lines to that length, including the backslash newline combo. The default 1144 line length is **70**. 1145 1146**DC_SIGINT_RESET** 1147 1148: If dc(1) is not in interactive mode (see the **INTERACTIVE MODE** section), 1149 then this environment variable has no effect because dc(1) exits on 1150 **SIGINT** when not in interactive mode. 1151 1152 However, when dc(1) is in interactive mode, then if this environment 1153 variable exists and contains an integer, a non-zero value makes dc(1) reset 1154 on **SIGINT**, rather than exit, and zero makes dc(1) exit. If this 1155 environment variable exists and is *not* an integer, then dc(1) will exit on 1156 **SIGINT**. 1157 1158 This environment variable overrides the default, which can be queried with 1159 the **-h** or **-\-help** options. 1160 1161**DC_TTY_MODE** 1162 1163: If TTY mode is *not* available (see the **TTY MODE** section), then this 1164 environment variable has no effect. 1165 1166 However, when TTY mode is available, then if this environment variable 1167 exists and contains an integer, then a non-zero value makes dc(1) use TTY 1168 mode, and zero makes dc(1) not use TTY mode. 1169 1170 This environment variable overrides the default, which can be queried with 1171 the **-h** or **-\-help** options. 1172 1173**DC_PROMPT** 1174 1175: If TTY mode is *not* available (see the **TTY MODE** section), then this 1176 environment variable has no effect. 1177 1178 However, when TTY mode is available, then if this environment variable 1179 exists and contains an integer, a non-zero value makes dc(1) use a prompt, 1180 and zero or a non-integer makes dc(1) not use a prompt. If this environment 1181 variable does not exist and **DC_TTY_MODE** does, then the value of the 1182 **DC_TTY_MODE** environment variable is used. 1183 1184 This environment variable and the **DC_TTY_MODE** environment variable 1185 override the default, which can be queried with the **-h** or **-\-help** 1186 options. 1187 1188# EXIT STATUS 1189 1190dc(1) returns the following exit statuses: 1191 1192**0** 1193 1194: No error. 1195 1196**1** 1197 1198: A math error occurred. This follows standard practice of using **1** for 1199 expected errors, since math errors will happen in the process of normal 1200 execution. 1201 1202 Math errors include divide by **0**, taking the square root of a negative 1203{{ A H N HN }} 1204 number, using a negative number as a bound for the pseudo-random number 1205 generator, attempting to convert a negative number to a hardware integer, 1206 overflow when converting a number to a hardware integer, overflow when 1207 calculating the size of a number, and attempting to use a non-integer where 1208 an integer is required. 1209 1210 Converting to a hardware integer happens for the second operand of the power 1211 (**\^**), places (**\@**), left shift (**H**), and right shift (**h**) 1212 operators. 1213{{ end }} 1214{{ E EH EN EHN }} 1215 number, attempting to convert a negative number to a hardware integer, 1216 overflow when converting a number to a hardware integer, overflow when 1217 calculating the size of a number, and attempting to use a non-integer where 1218 an integer is required. 1219 1220 Converting to a hardware integer happens for the second operand of the power 1221 (**\^**) operator. 1222{{ end }} 1223 1224**2** 1225 1226: A parse error occurred. 1227 1228 Parse errors include unexpected **EOF**, using an invalid character, failing 1229 to find the end of a string or comment, and using a token where it is 1230 invalid. 1231 1232**3** 1233 1234: A runtime error occurred. 1235 1236 Runtime errors include assigning an invalid number to any global (**ibase**, 1237 **obase**, or **scale**), giving a bad expression to a **read()** call, 1238 calling **read()** inside of a **read()** call, type errors (including 1239 attempting to execute a number), and attempting an operation when the stack 1240 has too few elements. 1241 1242**4** 1243 1244: A fatal error occurred. 1245 1246 Fatal errors include memory allocation errors, I/O errors, failing to open 1247 files, attempting to use files that do not have only ASCII characters (dc(1) 1248 only accepts ASCII characters), attempting to open a directory as a file, 1249 and giving invalid command-line options. 1250 1251The exit status **4** is special; when a fatal error occurs, dc(1) always exits 1252and returns **4**, no matter what mode dc(1) is in. 1253 1254The other statuses will only be returned when dc(1) is not in interactive mode 1255(see the **INTERACTIVE MODE** section), since dc(1) resets its state (see the 1256**RESET** section) and accepts more input when one of those errors occurs in 1257interactive mode. This is also the case when interactive mode is forced by the 1258**-i** flag or **-\-interactive** option. 1259 1260These exit statuses allow dc(1) to be used in shell scripting with error 1261checking, and its normal behavior can be forced by using the **-i** flag or 1262**-\-interactive** option. 1263 1264# INTERACTIVE MODE 1265 1266Like bc(1), dc(1) has an interactive mode and a non-interactive mode. 1267Interactive mode is turned on automatically when both **stdin** and **stdout** 1268are hooked to a terminal, but the **-i** flag and **-\-interactive** option can 1269turn it on in other situations. 1270 1271In interactive mode, dc(1) attempts to recover from errors (see the **RESET** 1272section), and in normal execution, flushes **stdout** as soon as execution is 1273done for the current input. dc(1) may also reset on **SIGINT** instead of exit, 1274depending on the contents of, or default for, the **DC_SIGINT_RESET** 1275environment variable (see the **ENVIRONMENT VARIABLES** section). 1276 1277# TTY MODE 1278 1279If **stdin**, **stdout**, and **stderr** are all connected to a TTY, then "TTY 1280mode" is considered to be available, and thus, dc(1) can turn on TTY mode, 1281subject to some settings. 1282 1283If there is the environment variable **DC_TTY_MODE** in the environment (see the 1284**ENVIRONMENT VARIABLES** section), then if that environment variable contains a 1285non-zero integer, dc(1) will turn on TTY mode when **stdin**, **stdout**, and 1286**stderr** are all connected to a TTY. If the **DC_TTY_MODE** environment 1287variable exists but is *not* a non-zero integer, then dc(1) will not turn TTY 1288mode on. 1289 1290If the environment variable **DC_TTY_MODE** does *not* exist, the default 1291setting is used. The default setting can be queried with the **-h** or 1292**-\-help** options. 1293 1294TTY mode is different from interactive mode because interactive mode is required 1295in the [bc(1) specification][1], and interactive mode requires only **stdin** 1296and **stdout** to be connected to a terminal. 1297 1298{{ A E N EN }} 1299## Command-Line History 1300 1301Command-line history is only enabled if TTY mode is, i.e., that **stdin**, 1302**stdout**, and **stderr** are connected to a TTY and the **DC_TTY_MODE** 1303environment variable (see the **ENVIRONMENT VARIABLES** section) and its default 1304do not disable TTY mode. See the **COMMAND LINE HISTORY** section for more 1305information. 1306{{ end }} 1307 1308## Prompt 1309 1310If TTY mode is available, then a prompt can be enabled. Like TTY mode itself, it 1311can be turned on or off with an environment variable: **DC_PROMPT** (see the 1312**ENVIRONMENT VARIABLES** section). 1313 1314If the environment variable **DC_PROMPT** exists and is a non-zero integer, then 1315the prompt is turned on when **stdin**, **stdout**, and **stderr** are connected 1316to a TTY and the **-P** and **-\-no-prompt** options were not used. The read 1317prompt will be turned on under the same conditions, except that the **-R** and 1318**-\-no-read-prompt** options must also not be used. 1319 1320However, if **DC_PROMPT** does not exist, the prompt can be enabled or disabled 1321with the **DC_TTY_MODE** environment variable, the **-P** and **-\-no-prompt** 1322options, and the **-R** and **-\-no-read-prompt** options. See the **ENVIRONMENT 1323VARIABLES** and **OPTIONS** sections for more details. 1324 1325# SIGNAL HANDLING 1326 1327Sending a **SIGINT** will cause dc(1) to do one of two things. 1328 1329If dc(1) is not in interactive mode (see the **INTERACTIVE MODE** section), or 1330the **DC_SIGINT_RESET** environment variable (see the **ENVIRONMENT VARIABLES** 1331section), or its default, is either not an integer or it is zero, dc(1) will 1332exit. 1333 1334However, if dc(1) is in interactive mode, and the **DC_SIGINT_RESET** or its 1335default is an integer and non-zero, then dc(1) will stop executing the current 1336input and reset (see the **RESET** section) upon receiving a **SIGINT**. 1337 1338Note that "current input" can mean one of two things. If dc(1) is processing 1339input from **stdin** in interactive mode, it will ask for more input. If dc(1) 1340is processing input from a file in interactive mode, it will stop processing the 1341file and start processing the next file, if one exists, or ask for input from 1342**stdin** if no other file exists. 1343 1344This means that if a **SIGINT** is sent to dc(1) as it is executing a file, it 1345can seem as though dc(1) did not respond to the signal since it will immediately 1346start executing the next file. This is by design; most files that users execute 1347when interacting with dc(1) have function definitions, which are quick to parse. 1348If a file takes a long time to execute, there may be a bug in that file. The 1349rest of the files could still be executed without problem, allowing the user to 1350continue. 1351 1352**SIGTERM** and **SIGQUIT** cause dc(1) to clean up and exit, and it uses the 1353{{ A E N EN }} 1354default handler for all other signals. The one exception is **SIGHUP**; in that 1355case, and only when dc(1) is in TTY mode (see the **TTY MODE** section), a 1356**SIGHUP** will cause dc(1) to clean up and exit. 1357{{ end }} 1358{{ H EH HN EHN }} 1359default handler for all other signals. 1360{{ end }} 1361 1362{{ A E N EN }} 1363# COMMAND LINE HISTORY 1364 1365dc(1) supports interactive command-line editing. 1366 1367If dc(1) can be in TTY mode (see the **TTY MODE** section), history can be 1368enabled. This means that command-line history can only be enabled when 1369**stdin**, **stdout**, and **stderr** are all connected to a TTY. 1370 1371Like TTY mode itself, it can be turned on or off with the environment variable 1372**DC_TTY_MODE** (see the **ENVIRONMENT VARIABLES** section). 1373 1374**Note**: tabs are converted to 8 spaces. 1375{{ end }} 1376 1377{{ A E H EH }} 1378# LOCALES 1379 1380This dc(1) ships with support for adding error messages for different locales 1381and thus, supports **LC_MESSAGES**. 1382{{ end }} 1383 1384# SEE ALSO 1385 1386bc(1) 1387 1388# STANDARDS 1389 1390The dc(1) utility operators are compliant with the operators in the bc(1) 1391[IEEE Std 1003.1-2017 (“POSIX.1-2017”)][1] specification. 1392 1393# BUGS 1394 1395None are known. Report bugs at https://git.yzena.com/gavin/bc. 1396 1397# AUTHOR 1398 1399Gavin D. Howard <gavin@yzena.com> and contributors. 1400 1401[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html 1402