This should be a lot more robust

Martin,

So I added a Xcode project, and added some few new test. I had to comment some out as you will need to do work in the engineering to double method - see what I did in my project (essentially return NaN if the input is garbage).

David