Forrest logo
back to the bc tool

bc:tldr:5360a

bc: Start an interactive session.
$ bc
try on your machine

The "bc" command stands for "basic calculator" and is used as a command-line calculator in Unix-based operating systems. It provides a simple calculator interface that allows users to perform various arithmetic operations and mathematical calculations.

Here are a few notable features and functionalities of the "bc" command:

  1. Arithmetic Operations: You can use "bc" to perform basic arithmetic operations such as addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).

  2. Mathematical Functions: "bc" supports various mathematical functions like square root, exponentiation, logarithm, trigonometric functions, and more. These functions can be accessed by using specific functions and predefined constants.

  3. Precision Control: "bc" allows you to specify the desired precision or number of decimal places for the calculation result. This is particularly useful when working with decimal numbers or when precision is crucial.

  4. Variable Assignment: You can assign values to variables and use them in calculations within "bc". This helps in creating more complex expressions or calculations that involve multiple steps.

  5. Conditional Statements and Loops: "bc" provides basic logical operations and control flow constructs, such as if-else statements and loops, allowing you to write more sophisticated calculations and scripts.

  6. Input and Output: "bc" allows input from files or direct user input through the command line. It also supports output formatting options to customize the display of calculation results.

Overall, "bc" is a versatile command-line calculator that provides a convenient way to perform calculations and mathematical operations directly from the command prompt.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the bc tool