Spam (madbodger) wrote,
Spam
madbodger

  • Mood:
  • Music:

Geekiness

I'm writing a data normalizer, and among its other functions, it converts latitudes and longitudes. I realized it should accept these in decimal or degrees, minutes, and seconds. Then I had to convert the latter to decimal. No problem, just divide minutes by 60 and seconds by 3600 and add. Well, not really. If you had input like "-77 18 41.64", the minutes and seconds are implicitly negative (like the degrees). No problem, I modified the code to make the minutes and seconds the same sign as the degrees.

But this wasn't quite correct either! What if I get some input like "-0 54 12.047"? After converting the degrees, I get zero, not negative zero. So I had to add even more code to check the original unconverted string to see if I had to change the sign. Not too hard in concept, but since the code already supported both numeric forms, and directions either prefix or postfix ("N 54 19 17.554 W 77 32 8.333" as well as "54 19 17.554N77 32 8.333W"), it took a little finagling to get everything right.

I should have just used yacc.

Subscribe

  • Turntable reminiscences

    My first record player was a cheap red and white plastic affair with which I could play my stack of bright yellow 78s. It was the kind that had a…

  • Fixing a Kodak Carousel slide projector

    I was going through old family slides with the old family slide projector and noticed the focus motor was running continuously. I did some quick…

  • Old-style Polaroid photography

    One day, fizzgig and I were shopping at a knickknack store and found chromed resin casts of old cameræ. We remarked how they would fit our…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 13 comments

  • Turntable reminiscences

    My first record player was a cheap red and white plastic affair with which I could play my stack of bright yellow 78s. It was the kind that had a…

  • Fixing a Kodak Carousel slide projector

    I was going through old family slides with the old family slide projector and noticed the focus motor was running continuously. I did some quick…

  • Old-style Polaroid photography

    One day, fizzgig and I were shopping at a knickknack store and found chromed resin casts of old cameræ. We remarked how they would fit our…