Simple and Easy-to-use calculator bc in Linux
1. About bc
Bc is an arbitrary precision calculator language. It is usually used as a calculator in linux and is easy to use. It is equivalent to a calculator in windows.
2. Supported Operators
Basic mathematical operations: + addition-subtraction * multiplication/division ^ exponent % Remainder
It also supports expressions, logical operations, and mathematical functions.
3. Use
Enter bc in linux
$ Bcbc 1.06 Copyright 1991-1994,199 7, 1998,200 0 Free Software Foundation, Inc. This is free software with absolutely no warranty. For details type 'warranty '.
Input the operation and press enter to output the operation result.
2 + 573*4127-252 ^ 386% 513/40
In the above example, 3/4 is 0. bc, and the default output is an integer. to display the decimal point, set it by scale = number. number is the number of digits after the decimal point.
Scale = 33/4. 750
You can enter multiple operations at a time, separated by semicolons (;), and return one operation after pressing enter.
2 + 5; 3x4; 3x100712300
Numerical Comparison
3> 403> 21
Logical expression
(3> 2) | (1 <2) 1 (3> 2) & (1> 2) 0
Enter quit to exit
3. MPS queue
Bc supports parameter input. Next, use the MPs queue.
$ Echo "3 + 4" | bc7
Semicolon; Separate multiple input
$ Echo "3/4; scale = 3; 3/4" | bc 0.750
Address: http://blog.csdn.net/yonggang7/article/details/37317571