I’ve got an interesting (read: geeky) story to share, but first a quick status update. We’re both in Chicago for the next two-week working session, and the excitement level’s as high as it’s ever been, save for maybe the first work session where we’d code every night til 6am.  This time we’re still working long hours but the schedule’s flipped around, so we’re up at 6 each morning instead.  It’s been a great change – we’re still getting lots of work done while staying a lot healthier.  Much of our excitement comes from the fact that we’re close to sharing a private Beta out to a large set of people.  As anyone who’s ever shipped software (or anything, for that matter) can tell you, when you get close to a ship date, everything seems to conspire against you to delay things as much as possible.  And so it is, our todo lists are growing each day.  What’s a sample task?  "Prepare for feedback: grow a thick skin." :)

<geek-out begins>

Onto the geek-out story.  Our project focuses on certain content and includes phone numbers.  We found a problem in the phone numbers database table where there were tons (figuratively, not literally a multiple of 2000lbs) of duplicate phone numbers, all of them "2147483647".   There were over 20,000 phone numbers in the table and over 2/3rds of them were all this mysterious phone number.  Who was this mysterious, popular person?  We had no idea – our problem was that all the numbers we were putting into the database were all unique, but somehow most of them were being transformed.  Perplexed, we approached the problem like any other high-functioning partnership – we started blaming each other.  :)    

We pored over every line of our Ruby on Rails code that handled the phone numbers, and set breakpoints at every stage of our data processing, but to no avail – the numbers seemed perfect right up til they were stored in the db, but were transformed once we pulled them back out.  After an hour of frustration, we randomly googled for "2147483647" and discovered it was a Mersenne Prime, which is a prime number that is one less than a power of 2.  Aha!  The problem was that we were stripping all the formatting from our phone number strings and storing the resulting 10-digit value in the database in an INT type column.  It just so happens that the 10-digit number 2,147,483,647 is 2^31 – 1 or 0x7FFFFFFF, the maximum signed integer value for any INT column.  So, every phone number whose digits were less than that value stored fine, and all phone numbers above it were stored as this max integer value, and the fix was simply to change the type to a STRING type instead.  As you’d expect, we were kicking ourselves (and each other) after discovering this.  Who knew such a little type declaration could cause such a headache?  I thought I’d gotten away from these problems forever when I switched out of a developer role at MS!  My ex-coworkers reading this are probably shaking their heads in shame. :D

</geek-out ends>

-JL

Powered by Qumana

If you enjoyed this post, make sure you subscribe to my RSS feed!

Other Two-Bit Posts

8 thoughts on “A Prime Conundrum

  1. good ol programming errors. i always felt dumb in my easy programming classes when it was a declaration error or something like that =P

  2. Yes, I’m positive I was one of those ex-coworkers you had in mind, shaking their heads in shame.

    (In case it wasn’t obvious, I in fact have lots o’ respect for you, I know how these mistakes happen even for the best devs. It’s still a pretty fucking hilarious bug though).

  3. Hello my loved one! I wish to say that this post is amazing, fantastic written and come with almost all significant infos. I’d like to appear far more posts like this .

  4. Apple skup olawa at this point has Rhapsody being an app, which is a wonderful start, but it’s currently hampered with the inability to store locally on your own iPod, and includes a dismal 64kbps little bit rate. If that changes, then it’ll somewhat negate this kind of advantage with the Zune, but this 10 songs monthly it’s still a large plus inside Zune Pass’ benefit.

  5. I and my guys happened to be checking out the good guidelines from your web page then the sudden developed an awful feeling I never expressed respect to the blog owner for those tips. Most of the ladies were absolutely warmed to learn all of them and have in effect in reality been making the most of those things. We appreciate you really being so considerate and also for obtaining such very good useful guides most people are really desirous to know about. Our own honest apologies for not expressing gratitude to earlier.

  6. Great beat ! I would like to apprentice at the same time as you amend your site, how could i subscribe for a weblog site? The account aided me a applicable deal. I had been a little bit familiar of this your broadcast provided brilliant clear concept

Leave a reply

required

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>