Wednesday, September 21, 2005

Fun with conversions

For about a week now off and on I've been working on adding simple conversion functions to iota-calc. I started this because, I got an email from a potential customer that wanted to know how much Crossword Forge cost in Australian Dollars. I fired up the calculator that came with Mac OS X Panther so that I could compute it. Unfortunately Apple's calculator kept crashing for me whenever I tried to update the calculator with the current exchange rates. I figured it was just a fluke with my system (my G5), so I tried it on my iBook, with the same results. I decided to go to the web to get the answer for this customer, and to write my own currency converter into iota-calc.

Since currency exchange rates vary day by day (even second by second), I would need to get the information from some service on the web. I found a 'SOAP' service that provided the current exchange rates updated every 15 minutes. This was fine for my needs but I couldn't get it to work in iota-calc. After trying for what seemed like eternity I gave up on that approach (later I found out from Mike Bailey (the author of the SOAP implementation in REALbasic), that he was having trouble as well). I instead decided to scrape the information I need from www.fxstreet.com. It works great, and I provide a link to fxstreet.com in my iota-calc interface for all those that need more detailed currency analysis. The really cool thing is that the currency conversions I do in iota-calc are always live (they aren't delayed by 15 minutes, and you don't have to send requests to update the rates on your local machine).

Once I had the currency converter in place though, I couldn't stop there. iota-calc, after all, is meant to be a calculator for programmers, so the currency converter seemed out of place and incomplete. I had to design a set of conversion utilities to make the feature look like part of a architected whole. So I went ahead and added other conversion utilities. One that converts from bits to Terabytes and everything in between and beyond (this one ties it properly into iota-calc's target audience (programmers)). I also added converters for length, area, volume, weights, and temperatures.

Although all of these things exist already in Apple's calculator I feel that my features are an improvement in many respects.
  • supports 140 different currencies instead of 40.

  • Updates to the current exchange rate automatically.

  • Includes bits to megabytes converter.

  • Includes more cooking measures in the volume converter (e.g. teaspoons and cups)

  • More accurate than Apple's converter (e.g. in Apples converter 1 yard = 2.9999 feet). I do this by not switching measurement systems unless I have to (e.g. yards to feet should stay in imperial measures)

  • Apple's calculator allows you to, in some cases, convert between standard imperial and U.S. imperial measures. Though it doesn't do so consistently and does so in a confusing way that could cause the user errors. e.g. You can choose between U.S. Gallons and Imperial Gallons but Quarts are left unspecified as to which measuring system they belong to. Through experimentation it seems that Apple's calculator uses U.S. style quart measures, but if you get your assumptions wrong, you could make a substantial error. Currently iota-calc avoids this whole issue, by clearing noting that it only uses U.S. imperial measures in all cases.


I haven't posted the new version of iota-calc yet. I will probably do that first thing tomorrow. I still need to test it to make sure there aren't any mistakes. Email me if you want to help me test.

No comments: