Forrest logo
tool overview
On this page you find all important commands for the CLI tool bc. If the command you are looking for is missing please ask our AI.

bc

The command line tool "bc" stands for "basic calculator." It is primarily used for performing arithmetic calculations in the command line interface.

Here are a few features and characteristics of "bc":

  1. Arbitrary Precision: "bc" supports arbitrary precision arithmetic, meaning it can handle calculations involving a large number of decimal places without losing precision.

  2. Interactive Mode: When executed without any arguments, "bc" opens an interactive shell that allows you to enter arithmetic expressions in a familiar calculator-like syntax. It evaluates the expressions and displays the results instantly.

  3. Scripting Support: "bc" can also be used to execute arithmetic expressions stored in a separate text file. This makes it useful for creating scripts that involve complex calculations.

  4. Mathematical Functions: In addition to basic arithmetic operations, "bc" supports various mathematical functions such as square roots, exponentiation, logarithms, and trigonometric functions.

  5. Variables and Control Flow: "bc" allows you to define and use variables for storing values. It also provides conditional statements and loops for controlling the flow of calculations.

  6. Output Formatting: The tool provides options to customize the precision, scale, and output format of the calculated results.

Overall, "bc" is a powerful command line calculator that can handle complex arithmetic calculations efficiently and accurately. It is often used in shell scripting, mathematical computations, and for quick calculations directly in the command line interface.

List of commands for bc:

  • bc:tldr:5360a bc: Start an interactive session.
    $ bc
    try on your machine
    explain this command
  • bc:tldr:924ca bc: Execute a script.
    $ bc ${path-to-script-bc}
    try on your machine
    explain this command
  • bc:tldr:96e37 bc: Calculate a sine/cosine/arctangent/natural logarithm/exponential function using `mathlib`.
    $ bc --mathlib --expression='${select}(${1})'
    try on your machine
    explain this command
  • bc:tldr:c5533 bc: Calculate an expression.
    $ bc --expression='${5 - 3}'
    try on your machine
    explain this command
  • bc:tldr:d987a bc: Start an interactive session with the standard math library enabled.
    $ bc --mathlib
    try on your machine
    explain this command
  • bc:tldr:e5fc5 bc: Calculate an expression with the specified scale.
    $ bc --expression='scale = ${10}; ${5 - 3}'
    try on your machine
    explain this command
tool overview