Ich bin ein Dummkopf
Anyone outside of certain European and South American countries that use a comma as the decimal separator in numbers can safely ignore this posting. Everyone else read on.
Update (04/09/09) : Version 1.0.1 approved and fixes this issue
Early this morning we started getting some bug reports about wrong conversions in Convertbot. After some troubleshooting we determined that this is a problem that happens when a Phone’s International Region Format is set to a locale that uses a comma as the decimal separator (i.e. 1000,00 for one thousand). After a bit of digging around through the code I found the problem and fixed it with a very simple addition to the code. Within another hour or so we fully sanity checked the app and submitted version 1.0.1 to Apple. Assuming things go as planned that release should be approved within the next 7 days, though unfortunately this is totally out of our control.
So how did this happen?
In order to convert from one unit to another there needs to be a formula for the conversion. For example from Celsius to Kelvin we store something like K = C + 273.15 as a string. In order to use that formula we have to do some parsing on the string that isn’t very interesting to anyone but geeks like me. The problem however comes when we get to that 273.15 number. We’re using a class called an NSNumberFormatter which abstracts a lot of the complexity of turning numbers into strings and vice versa. The NSNumberFormatter code uses the Region Format settings to decide exactly what the user would expect a number to look like. Since some of the locales use comma as the decimal separator NSNumberFormatter was assuming that 273.15 meant 273 which is what’s causing all the havoc during conversions. For currencies a conversion of $1.35 to €1.00 would just become $1 to €1. The Fix was a single line of code to tell NSNumberFormatter to expect a period as the decimal separator when reading in data from the conversion formulas.
Obviously regardless of how cool a unit conversion application looks its pretty useless if you can’t depend on it to correctly perform calculations. Because of this there is a lot of automated testing code that was built as part of Convertbot. Every single conversion is exercised a number of times through these tests so that we can avoid a situation like this. Unfortunately neither the automated tests nor any of the beta testers ever tested using a comma as a separator. This is obviously in the process of being changed and each of the tests will be run through multiple locales to make sure this particular problem can’t happen again.
Again we hope Apple approves this new release as soon as possible. The temporary work around for folks affected by this bug is to change their Region Format to one that doesn’t use a comma. Simply go to the Settings app and Navigate to General -> International -> Region Format and chose a different format, United States as an example.
I’m personally very embarrassed by this bug and its something that should never have happened. There’s really no excuse for it and we are very sorry that it happened. As we’ve shown with Weightbot we are only interested in producing high quality applications and we are very concerned with making our applications work properly for all countries. We’ve localized Weightbot for over 10 countries and we’ll probably do the same for Convertbot. We respect and go out of our way to respect any locale differences whenever possible (Stones as a weight unit available in the UK). Again we are sorry and will do better next time.