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.
Subscribe to Newsletter
Software Updatesmore updates
- Vizzywig 8xHD price tag now a very affordable $49.99
- Automatic targets teen drivers with License+ service
- Dropbox adds support for TouchID
- YouTube for iOS gets updated with full support for iPhone 6 and 6 Plus
- iOS 8.0.1 update now available (Updated -- Don't update!)
- NFL Mobile updated for 2014 Season with new Fantasy Football features, NFL Now integration