Forrest logo
back to the bc tool

bc:tldr:e5fc5

bc: Calculate an expression with the specified scale.
$ bc --expression='scale = ${10}; ${5 - 3}'
try on your machine

The bc command is a command-line calculator in Unix-like operating systems. It stands for "Basic Calculator" and is used to perform arithmetic operations.

In the given command, bc is followed by the --expression option which allows you to specify an expression or equation to be evaluated.

The expression scale = ${10}; ${5 - 3} consists of two parts separated by a semicolon:

  1. scale = ${10};:

    • scale is a special variable in bc that determines the number of digits after the decimal point in the result.
    • ${10} is a parameter representing the value 10 which is assigned to scale.
  2. ${5 - 3}:

    • ${5 - 3} is the arithmetic expression 5 - 3, which subtracts 3 from 5.

Putting it all together, running the command bc --expression='scale = ${10}; ${5 - 3}' will execute the bc calculator with the expression. The value of scale will be set to 10, and the result of 5 - 3 will be displayed based on the specified scale.

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