2017-12-15 17:51:17 +00:00
# dc
> An arbitrary precision calculator. Uses reverse polish notation (RPN).
2022-01-22 06:00:09 +00:00
> See also: `bc`.
2021-04-18 16:40:06 +01:00
> More information: <https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html>.
2017-12-15 17:51:17 +00:00
2022-01-22 06:00:09 +00:00
- Start an interactive session:
2017-12-15 17:51:17 +00:00
`dc`
2022-01-22 06:00:09 +00:00
- Execute a script:
2017-12-15 22:12:48 +00:00
2022-01-22 06:00:09 +00:00
`dc {{path/to/script.dc}}`
2017-12-15 22:12:48 +00:00
2022-01-22 06:00:09 +00:00
- Calculate an expression with the specified scale:
2017-12-15 17:51:17 +00:00
2022-01-22 06:00:09 +00:00
`dc --expression='{{10}} k {{5 3 /}} p'`
2017-12-15 17:51:17 +00:00
2022-01-22 06:00:09 +00:00
- Calculate 4 times 5 (4 5 *), subtract 17 (17 -), and [p]rint the output:
2017-12-15 17:51:17 +00:00
2022-01-22 06:00:09 +00:00
`dc --expression='4 5 * 17 - p'`
2017-12-15 17:51:17 +00:00
2022-01-22 06:00:09 +00:00
- Set number of decimal places to 7 (7 k), calculate 5 divided by -3 (5 _3 /) and [p]rint:
2017-12-15 17:51:17 +00:00
2022-01-22 06:00:09 +00:00
`dc --expression='7 k 5 _3 / p'`
- Calculate the golden ratio, phi: set number of decimal places to 100 (100 k), square root of 5 (5 v) plus 1 (1 +), divided by 2 (2 /), and [p]rint result:
`dc --expression='100 k 5 v 1 + 2 / p'`