首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

Terminal 计算器效能 Terminal Tip: Command Line Calculator

2013-07-16 
Terminal 计算器功能 Terminal Tip: Command Line CalculatorMac OS X ships with a powerful and useful

Terminal 计算器功能 Terminal Tip: Command Line Calculator

Mac OS X ships with a powerful and useful command-line calculator called bc. GNU bc provides an arbitrary precision calculator that allows you to type in expressions for immediate calculation.

?

It uses the standard conventions for computer arithmetic, i.e. + and - are addition and subtraction, * and / are multiplication and division, ^ is exponentiation. So to multiple, say, 193 by two thirds, you'd enter 193 * 2 / 3 and press return. Parentheses set the order of evaluation, just as they would in a normal arithmetic statement or in a computer language. e.g. (20 / 3) ^ 5 performs the division before the exponentiation.

?

You can also use variables with bc. Just assign them using an "=" command. For example, you can set your principal to 100 with principal=100. The special scale variable indicates the number of digits to show after the decimal point.

?

Enter "quit" to leave bc.

?

There's a lot more you can do with bc--it's really a full interactive programming language that goes way beyond the simple convenience of quick calculations. To learn about bc, type man bc from the command line.

?

from: http://www.tuaw.com/2007/04/24/terminal-tip-command-line-calculator/

?

热点排行