snippetbashTip
bc — An arbitrary precision calculator language. See also: `dc`. More information: <https://keith.github.
Viewed 0 times
commandlanguageclibccalculatorarbitraryprecisionsee
macos
Problem
How to use the
bc command: An arbitrary precision calculator language. See also: dc. More information: <https://keith.github.io/xcode-man-pages/bc.1.html>.Solution
bc — An arbitrary precision calculator language. See also: dc. More information: <https://keith.github.io/xcode-man-pages/bc.1.html>.Start an interactive session:
bcStart an interactive session with the standard math library enabled:
bc --mathlibCalculate 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}})'Code Snippets
Start an interactive session
bcStart an interactive session with the standard math library enabled
bc --mathlibCalculate 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}}'Context
tldr-pages: osx/bc
Revisions (0)
No revisions yet.