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.
Mac OS X ships with a powerful and useful command-line calculator called bc. GNU bc provides an arbitrary precision calculator that allows...
Subscribe to Newsletter
Software Updatesmore updates
- Daylite 5 adds refinements to the business management app
- 1Password 4.5 for iOS gains features, slims down
- IFTTT for iPad brings service/device mashups to your favorite tablet
- Daily App: Rormix brings indie music videos to your iPhone and iPad
- Pebble updates its iOS app with new apps, sharing options and v2.1 fix
- PSA: Pebble for iOS v.2.1 update contains critical flaw that breaks the app - Update