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
- Readdle rolls out PDF Expert 5: iCloud support, shared folder with Documents by Readdle
- FlightTrack 5: new look and features just in time for holiday travel
- HBO Go for iOS update adds Google Chromecast support
- Haiku Deck updates iPad app, launches web-based cloud version
- Weather Underground iPhone app gets crowdsourced weather, iOS 7 style
- Apple updates iMovie, adds support for older Macs