Linux calculator commands

Source: Internet
Author: User

Linux comes with two commands that support basic mathematical computing. If you do not want to use commands, you can use python or other
Two commands are easy to remember. One is that dc is actually an expression evaluate stack operation, and the other is bc, which is actually an explanatory language and supports various while if operations.
 
1: The following common commands are supported:
 
+-*/% ^ | V (initiator)
 
It is also very convenient to use, for example, to calculate 1 + 1 =?
After entering the dc command, enter an expression factor in each line, for example, 1 +
4th p indicates that the number of operations on the stack is displayed. For example, here is 1 +.
 
Java code
$ Dc
1
1
+
P
2
The specific use can be man dc, and other register operations are also supported.
 
2: Next, let's take a look at the bc Command, which has powerful functions. Here we will directly reference an introductory article by someone else.
Linux calculator bc command
Http://www.heiqu.com/show-27997-1.html
 
The following is an example of the above 1 + 1,
 
Java code
$ Bc
1 + 2 + 3 + 4 + 5
15
 
 
In comparison, dc operations are more like evaluating the suffix expression on the computer stack, while bc is the general infix expression.

Author: "dikar cloud mozhu"
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.