I'm not sure if you're aware of Google's built-in calculator, but it's totally awesome. It does all sorts of basic calculations, almost any unit conversion you can dream up, and for you programmers, it's great for doing base conversions. But opening a web browser to www.google.com just to make sure you converted
0x34 to decimal in your head correctly, isn't always convenient (this is of course assuming that no other calculators exist, such as
bc ;-) ).
So, I threw together a very simple command line interface to Google Calculator -- aptly named
gcalc. It's also a good example of how Cocoa's powerful classes can let you whip up useful tools quickly, much like a scripting language. The help screen shows some example usages:
gcalc version 0.1 by Greg Miller
Usage: gcalc [-d] <calculator query>
example: gcalc "5+2*2"
example: gcalc 5!
example: gcalc "sqrt(-4)"
example: gcalc "160 pounds * 4000 feet in calories"
example: gcalc avogadros number
example: gcalc 0b110111010 + 0x33 in decimal
example: gcalc 22 lira in yen
example: gcalc 2 to the power of 5
You can download the source and a prebuilt universal binary from the Google code project page at http://code.google.com/p/uj-gcalc/
Or if you just want to glance at the source, you can check it out here: