• KattMan (cs)

    FRIST! and early

    Treat all numbers as characters unless you need to do math on them.

  • Coffee Hound (unregistered)
    1. PHP (XML?)
    2. ???
    3. Profit!

    Now we know that step 2 is: store phone number as int (preferably while working in Dallas)... then charge consulting fees b/c the client mucked with YOUR production code... Flawless!

  • Gizzmo (unregistered)

    What, and you didn't notice that 2147483647 is (2^31)-1? Sheesh. :)

  • Pista (unregistered)

    Well, you seem to have kicked yourself in the butt, but at least you learned the lesson. For yourself and for a lot of us :D

  • Lone Phone Ranger (The bit-masked man) (unregistered)

    I guess computers in Dallas adopt wild west slang when they type guess and internally monologue to themselves

  • Manadar (unregistered)

    Only in Dallas!

    Quite literally.

  • SODOFFFFF (unregistered)

    I must say,I didn't expect this from the first line of the story,good job

  • Kevin D (unregistered)

    I live in the 989!!

  • dork (unregistered)

    now whos gonna call the max int32 phone number and try to convince them if they switch to at&t they will get full 64bits of service!

  • Dave the Destroyer (unregistered)

    As the first commenter alluded to isn't the real WTF here using numbers to store telephone numbers?

  • Rick (cs) in reply to KattMan
    KattMan:
    FRIST! and early

    Treat all numbers as characters unless you need to do math on them.

    TRWTF - A frist comment that is also correct.

    I learned this lesson about numbers about 3 decades ago.

    The lesson that I learned more recently is "Don't use XML unless you have a schema or at least a dtd."

  • flats (unregistered) in reply to Dave the Destroyer
    Dave the Destroyer:
    As the first commenter alluded to isn't the real WTF here using numbers to store telephone numbers?
    I'd excuse him for not reading the whole article, in his rush to be a first poster, but yes, the submitter did realize that.

    My first thought was "How on earth do you not recognize INT_MAX?" but I hadn't considered 1) someone would be living in a 214 area code, where that number would look sane, and 2) (which is much weirder to me) that young developers could have very well never developed on a 32-bit system.

  • Carl (unregistered)

    Storing a phone number as an integer is definitely a WTF, but so is having a development server that's configured differently than the production one.

  • ekolis (cs)

    I feel sorry for whoever has that number. I wonder if his name is Max?

  • KattMan (cs) in reply to flats
    flats:
    I'd excuse him for not reading the whole article, in his rush to be a first poster, but yes, the submitter did realize that.

    I did read the whole article first, but always felt that simply posting "FRIST" was a bit inane (some would say insane).

  • Shinobu (unregistered)

    We've had an extensive discussion about phone numbers before. Plus some filler text because Akismet doesn't recognise that this an internal cross-thread link.

  • jc (unregistered) in reply to Gizzmo

    you do realize that in php, all integers are signed, hence the one missing bit?

  • Mike (unregistered)

    TRWTF: Languages that hide exceptions and returns random crapola as data. Nice!

  • notromda (cs) in reply to Mike
    Mike:
    TRWTF: Crapola Languages that hide exceptions and returns random crapola as data. Nice!

    FTFY

  • Dion (unregistered)

    The explanation explains that there is some magic code converting XML to arrays in a couple of steps. It seems to me that the real WTF is that the XML API he gets the data from classifies the phone numbers as numbers.

  • Geoff (unregistered)

    Not a PHP guy so I don't know but, if you try to convert a string to an int and its to big you get the largest possible signed integer value? Its not an exception, or overflow error?

    What the hell kind of sense does that make?

  • foo (unregistered)

    Let's see, TRWTFs are:

    • Type-guessing -- honestly, in all my programming work I never needed to type-guess. Either the input fits the expected type, or it's invalid.
    • Not immediately thinking of 2^31 when seeing a 10-digit number starting with 21... (OK, slight excuses for the Dallas coincidence, but when a certain "magic" value keeps popping up, you better look what kind of value it actually is.)
    • PHP doing saturation rounding, apparently without any warning, in a type-cast
    • PHP itself
    • Testing on a different configuration that production
    • Storing phone numbers (or zip codes etc.) as numbers
    • The US numbering system :) -- many countries' phone numbers start with an initial 0, so the previous mistake would show much earlier.
    • The article:
    • Typo/grammar error in the first sentence
    • "2,147,483,647 is the highest integer value addressable on 32-bit systems". Triply wrong: (a) The highest signed integer, (b) representable, not addressable, (c) in a single register (64 bit integers stored in two registers are not that exotic, though maybe in PHP)
    • The comments, including this one
    • Akismet, of course
  • Dan (unregistered)

    Did anyone try calling the number? If it was available, I'd grab it. I wonder how many calls they get for this reason...

  • The MAZZTer (cs) in reply to KattMan
    KattMan:
    FRIST! and early

    Treat all numbers as characters unless you need to do math on them.

    I assume you mean PHONE numbers, otherwise this is just silly.

  • wtf (unregistered)

    The real WTF is a 32bit server.

  • @Deprecated (cs) in reply to dork
    dork:
    now whos gonna call the max int32 phone number and try to convince them if they switch to at&t they will get full 64bits of service!

    Tooooo funny! +2^31

  • DonaldK (unregistered)

    Whahahaha 214 dialing code... you would have picked up on the problem a lot earlier in another city...

    Thanks this was entertaining.

    Captcha "damnum" ... hiehie that damnum won't fit into a 32 bit int...!

  • PiisAWheeL (cs) in reply to Rick
    Rick:
    The lesson that I learned more recently is "Don't use XML."
    FTFY.
  • Matthew (unregistered)

    A fairly weak story... a relatively common error that everyone makes at least once in their life, and nothing really that fantastic or funny happened as a result. In the end, pretty much your run of the mill bugfix.

    Oh, and TRWTF is PHP.

  • Anketam (cs) in reply to Gizzmo
    Gizzmo:
    What, and you didn't notice that 2147483647 is (2^31)-1? Sheesh. :)
    Yea as soon as I saw the 2147 I knew it was a 2^x just had to figure out what x was. That is what you get for storing a string as a number, then again it is php and types are so retro.
  • Ben Jammin (unregistered) in reply to The MAZZTer
    The MAZZTer:
    KattMan:
    FRIST! and early

    Treat all numbers as characters unless you need to do math on them.

    I assume you mean PHONE numbers, otherwise this is just silly.

    I generally do postal codes as strings, too. Granted us Merkins generally only use numbers, whilst other countries mix in some letters (some as close as Canada) so you may not have a number only postal code.

  • Vilx- (unregistered)

    [Insert mandatory generic anti-PHP rant here]

  • John Winters (unregistered)

    This brings me on to one of my pet peeves - web sites that insist you have to enter your phone number without any punctuation or spaces in it.

    It apparently doesn't matter to the programmer that the number would normally have spaces in it - the web site insists the user has to take the spaces out. Two points:

    1. Why insist on storing the numbers in an unconventional format? (perhaps so they can be stored in an int?)
    2. If you must have them that way, then you (the programmer) massage them after input. Don't expect the user to do it for you.

    Captcah: saepius - a very wise comment.

  • The Doctor (unregistered)

    It's not often that people post WTF's that they're resposible for here...

  • hymie (cs) in reply to The MAZZTer
    The MAZZTer:
    KattMan:
    FRIST! and early

    Treat all numbers as characters unless you need to do math on them.

    I assume you mean PHONE numbers, otherwise this is just silly.

    You don't have numeric postal codes, numeric identification (Social Security) codes, numeric part numbers ... ?

  • toshir0 (cs) in reply to ekolis
    ekolis:
    I feel sorry for whoever has that number. I wonder if his name is Max?
    Dan:
    Did anyone try calling the number? If it was available, I'd grab it. I wonder how many calls they get for this reason...
    I third that. I can picture the guy totally going *cluster F-bomb* at each other call...
  • KattMan (cs) in reply to hymie
    hymie:
    The MAZZTer:
    KattMan:
    FRIST! and early

    Treat all numbers as characters unless you need to do math on them.

    I assume you mean PHONE numbers, otherwise this is just silly.

    You don't have numeric postal codes, numeric identification (Social Security) codes, numeric part numbers ... ?

    I'll just wait for future "numbers that sholuld be strings WTFs" from the Mazzter. I'm sure hilarity will ensue since we have warned him.

    Yes part numbers, SSN's, drivers license numbers, document numbers, customer numbers, etc, should all be strings. Cost, amount to order, inventory levels, days till end, etc should be numbers as you will eventually do math on them.

  • Chuck Lester (unregistered)

    Congratulations on being the frist person to report your OWN WTF!!

  • Web Dude (unregistered)

    A dubstep joke on TDWTF! How modern!

  • pitchingchris (cs) in reply to foo
    foo:
    - The US numbering system :) -- many countries' phone numbers start with an initial 0, so the previous mistake would show much earlier.

    Its not the US numbering system at fault, its the idiot who tried to put it a phone number into an int.

  • Rodnas (unregistered)

    2,147,483,647th (so not frist ey)

  • willaien (unregistered)

    PHP does automatic type casting in some cases, and won't even let you specify a type. So, the big WTF is using PHP in a production system.

    Veekun has an excellent article on why PHP is a bad idea for any project of sufficient size to warrant a language be used.

    Akismet seems to think I'm spamming up the joint, so adding a bit of text below the URL.

  • Cbuttius (unregistered)

    Sorry, the number you have called has been changed.

    Please redial 9223372036854775807

  • Spoe (unregistered) in reply to Geoff
    Geoff:
    Not a PHP guy so I don't know but, if you try to convert a string to an int and its to big you get the largest possible signed integer value? Its not an exception, or overflow error?

    Yep. Much like many overflow conditions in C, e.g.:

    int foo ( int x) {
        return ( x+1 ) > x;
    }
    int main ( void ) {
        printf ("%d\n", ( INT_MAX+1 ) > INT_MAX );
        printf ("%d\n", foo ( INT_MAX ));
        return 0;
    }

    GCC (and several other compilers) with -O2 will output: 1 0

    Meaning INT_MAX + 1 is both greater than and less than INT_MAX depending on how it's calculated.

    No error is reported for the overflow. As I understand it, the behavior in this case is valid per the C99 spec since INT_MAX + 1 represents undefined behavior: the compiler can do what it wants.

    I don't see C receiving the same level of disrespect as PHP.

  • A Person (unregistered) in reply to Rodnas

    Started at a new job about 6 months ago. Week 2 I am putting together some tables including you guessed it a telephone number.

    Boss looks at it later. 'Youre storing a phone number as text, why?'

    Little perplexed as boss is supposed to be a programmer.

    'Well you never need to perform arithemtic on it so this avoids any potential unintended math operations being performed on it'

    I expected a sage nod and for him to move on. What actually happened was the 3 other developers and my boss looked at me as if I was insane.

    It got stored as an int, and I realised I'm not going to learn anything here.

  • Spoe (unregistered) in reply to Spoe
    Spoe:
    GCC (and several other compilers) with -O2 will output: 1 0

    Correction: 0 1

  • Bubbah Ewing (unregistered) in reply to Manadar

    This must have been over 15 years ago.

    Around that time they "divided" Dallas into 2 area codes, 972 and 214 with the old code being the "inner" area. About 4 years after that they added the 469 area code as we consumed all the 972 numbers. Now it's an amalgamated 214/469/972 block where your neighbor could be assigned a different area code than you and you could have a phone number that is "next to" one that is a 1 hour drive away.

  • pantsman (unregistered) in reply to A Person

    Started at a new job. They are using PHP. Realised I'm not going to learn anything here.

  • callcopse (cs) in reply to Lone Phone Ranger (The bit-masked man)
    Lone Phone Ranger (The bit-masked man):
    I guess computers in Dallas adopt wild west slang when they type guess and internally monologue to themselves

    Of course. I think they would look, or see their avatars as, a little like Yosemite Sam. Ooohhh that rackin, frackin PHP ...

  • Cbuttius (unregistered)

    A few years ago between jobs I decided to teach myself PHP as I wanted to learn a bit more about it.

    The main WTF as I saw it that having a large amount of server-side scripting was likely to be slow on the server. However a small amount, or for a small intranet web-service with a few users, it isn't such a bad thing.

    Of course with any language, there will be WTF uses of it.

    I never got to write a project of any size to discover some of its WTF-ness, although it seemed at the time that it could integrate with C libraries quite well that you could actually write large amounts of your web-service code in C (or C++ with a C interface) and use PHP as a simple thin layer.

Leave a comment on “Confessions: The Phone Number”

Log In or post as a guest

Replying to comment #:

« Return to Article