Команда bc

Calculator.

Синтаксис

bc [-c] [-l] [file]

-cCompile only. The output is dc commands that are sent to the standard output.
-lDefine the math functions and initialize scale to 20, instead of the default zero.
fileName of the file that contains the bc commands to be calculated this is not a necessary command.

Usage

LA letter a-z
EAn expression: a (mathematical or logical) value, an operand that takes a value, or a combination of operands and operators that evaluates to a value.
SStatement
/* and /*Comment
sqrt ( E )Square root
length ( E )Number of significant decimal digits.
scale ( E )Number of digits right of decimal point.
quitExits the bc command.

Available Operators

+ - * / % ^
(% is remainder; ^ is power)

++ -- (prefix and postfix; apply to names)

== <= >= != < > = =+ =- =* =/ =% =^

Примеры

bc cal.txt = Would result in 3, see below notes.

Within the cal.txt file you could have a simple statement such as:

/* Add the value 1+2 /*
1+2
quit

When running the above command you will receive the results of the cal.txt file. Which in this case would be 3.

Обратно к списку команд