diff --git a/pages/common/bc.md b/pages/common/bc.md index 9a7f091599..e6abc6992b 100644 --- a/pages/common/bc.md +++ b/pages/common/bc.md @@ -1,20 +1,29 @@ # bc > An arbitrary precision calculator language. -> More information: . +> See also: `dc`. +> More information: . -- Start `bc` in interactive mode using the standard math library: +- Start an interactive session: -`bc -l` +`bc` -- Calculate the result of an expression: +- Start an interactive session with the standard math library enabled: -`bc <<< "(1 + 2) * 2 ^ 2"` +`bc --mathlib` -- Calculate the result of an expression and force the number of decimal places to 10: +- Calculate an expression: -`bc <<< "scale=10; 5 / 3"` +`echo '{{5 / 3}}' | bc` -- Calculate the result of an expression with sine and cosine using `mathlib`: +- Execute a script: -`bc -l <<< "s(1) + c(1)"` +`bc {{path/to/script.bc}}` + +- Calculate an expression with the specified scale: + +`echo 'scale = {{10}}; {{5 / 3}}' | bc` + +- Calculate a sine/cosine/arctangent/natural logarithm/exponential function using `mathlib`: + +`echo '{{s|c|a|l|e}}({{1}})' | bc --mathlib` diff --git a/pages/common/dc.md b/pages/common/dc.md index 878085669f..231fd8b351 100644 --- a/pages/common/dc.md +++ b/pages/common/dc.md @@ -1,24 +1,29 @@ # dc > An arbitrary precision calculator. Uses reverse polish notation (RPN). +> See also: `bc`. > More information: . -- Run calculator in interactive mode: +- Start an interactive session: `dc` -- Execute dc script in file: +- Execute a script: -`dc -f {{file}}` +`dc {{path/to/script.dc}}` -- Calculate 4 times 5 [4 5 *], subtract 17 [17 -], and [p]rint the output (using echo): +- Calculate an expression with the specified scale: -`echo "4 5 * 17 - p"| dc` +`dc --expression='{{10}} k {{5 3 /}} p'` -- Set number of decimal places to 7 [7 k], calculate 5 divided by -3 [5 _3 /] and [p]rint (using dc -e): +- Calculate 4 times 5 (4 5 *), subtract 17 (17 -), and [p]rint the output: -`dc -e "7 k 5 _3 / p"` +`dc --expression='4 5 * 17 - 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: +- Set number of decimal places to 7 (7 k), calculate 5 divided by -3 (5 _3 /) and [p]rint: -`dc -e "100 k 5 v 1 + 2 / p"` +`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'` diff --git a/pages/osx/bc.md b/pages/osx/bc.md new file mode 100644 index 0000000000..8caabda93a --- /dev/null +++ b/pages/osx/bc.md @@ -0,0 +1,29 @@ +# bc + +> An arbitrary precision calculator language. +> See also: `dc`. +> More information: . + +- Start an interactive session: + +`bc` + +- Start an interactive session with the standard math library enabled: + +`bc --mathlib` + +- Calculate an expression: + +`bc --expression='{{5 / 3}}'` + +- Execute a script: + +`bc {{path/to/script.bc}}` + +- Calculate an expression with the specified scale: + +`bc --expression='scale = {{10}}; {{5 / 3}}'` + +- Calculate a sine/cosine/arctangent/natural logarithm/exponential function using `mathlib`: + +`bc --mathlib --expression='{{s|c|a|l|e}}({{1}})'`