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."
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.
Powered by Qumana