Recently I discovered that the suggestions that are built into the search bar of Internet Explorer and Firefox expose results from the Google calculator:
So I fired up Fiddler to look where those suggestion requests where going to and found the following URL (for the request 1+1):
http://suggestqueries.google.com/complete/search?output=firefox&client=IE8&hl=en&qu=1%2B1
The answer to that request was a little JSON which looked like the following:
I pretty-printed the output a bit, since it comes out as one long line. As you can see, there are two nested arrays, the first element of the outer one being the search query and the inner one containing the suggestions. If the query was processed by the Google calculator the first element of the suggestions is the result.
Knowing that I hacked together a little program that sends its arguments as a search query to Google and prints the first suggestion (which hopefully is a calculator result):
Mostly I like the ability for unit conversion. Although not everything works. And unfortunately requests for physical constants don't yield a result, which they do, however, when using Google search directly. So that may be an area of improvement.
The program was written in C# 2.0 and uses LitJSON for JSON parsing. It runs on Mono as well, though I haven't tried to build it there, but since it's all .NET 2.0 it should work without problems.
Executable as well as source code is attached.
UPDATE (2008–10–26 00:34): I have updated source and executable as follows: