i think mischief is onto something. when you find yourself going slightly loopy in complex code, it's often an indication to refactor design. as a lot of time it's not super ingenious code that "wins"; simpler code with a simple interface is often more flexible in the long run.
processing the input to produce a internal representation in ISO units or other consistent units, allows good flexibility.
if you're interested following that path, have a look (and infer the logic) on unit conversion apps such as those for iphone.