Showing posts with label Complex Arithmetic using Binary calculator. Show all posts
Showing posts with label Complex Arithmetic using Binary calculator. Show all posts

Wednesday, July 18, 2012

Complex Arithmetic using Linux Binary calculator

Lets say you want to execute the below arithmetic expression using Binary calculator (bc):
((10*10)+100)/4. The expected value for this arithmetic expression is 50.

The syntax using 'bc' would be :
# echo "10*10;.+100;./4" | bc
100
200
50
#

Please note the semicolon(;) and period (.) used in-between.

Other version using 'last' keyword:
# echo "10*10;last+100;last/4" | bc
100
200
50
#

The period (.) or 'last' keyword denotes result of previous execution.