tldr/pages/common/bc.md

30 lines
584 B
Markdown
Raw Permalink Normal View History

2015-12-12 20:37:45 +00:00
# bc
2021-03-31 11:16:18 +01:00
> An arbitrary precision calculator language.
2022-01-22 06:00:09 +00:00
> See also: `dc`.
> More information: <https://manned.org/man/bc.1>.
2015-12-12 20:37:45 +00:00
2022-01-22 06:00:09 +00:00
- Start an interactive session:
2022-01-22 06:00:09 +00:00
`bc`
2022-01-22 06:00:09 +00:00
- Start an interactive session with the standard math library enabled:
2015-12-12 20:37:45 +00:00
2022-01-22 06:00:09 +00:00
`bc --mathlib`
2015-12-12 20:37:45 +00:00
2022-01-22 06:00:09 +00:00
- Calculate an expression:
2015-12-12 20:37:45 +00:00
2022-01-22 06:00:09 +00:00
`echo '{{5 / 3}}' | bc`
2015-12-12 20:37:45 +00:00
2022-01-22 06:00:09 +00:00
- Execute a script:
2015-12-12 20:37:45 +00:00
2022-01-22 06:00:09 +00:00
`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`