• airdrik (unregistered) in reply to Chuck Lester
    Chuck Lester:
    Congratulations on being the frist person to report your OWN WTF!!
    Because no one has ever reported their own WTF before. Alas if only the designer of Akismet would come forth and report the WTF that is Akismet
  • Drtfsxzjkl (unregistered) in reply to willaien
    willaien:
    Akismet seems to think I'm spamming up the joint, so adding a bit of text below the URL.
    Akismet's algorithm is (or at least includes): if (post.endsWithURL()) then {is_spam = true}. I've yet to see a single counterexample.
  • Andrew (unregistered) in reply to wtf
    wtf:
    The real WTF is a 32bit server.
    I was going to say the same thing, but then I saw a bunch of in use P3 servers in the closet yesterday.

    Oh snap!

  • (cs) in reply to KattMan
    KattMan:
    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.

    At the risk of being tautological, if you don't need to do math on the thing, it's not a number, it's just an identifier.

    I'll add ISBNs and PINs to KattMan's list, and subclass part numbers as UPCs and EANs.

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

    No matter how much I look at it, I will always see "crapola" as a combination of "crap" and "cola," and so I will always think of it as the flavor of Pepsi Blue. (Or Crystal Pepsi, if you prefer.)

  • foo (unregistered) in reply to A Person
    A Person:
    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.

    The correct answer would have been: "Because it's not a number, just a sequence of digits." Of course, the chances he'd understand the difference are small.

    A more pragmatic answer would be: "So you can preserve the puctuation and don't need extra code to remove it on input and add it on output", or "if you ever want to go international, note that some countries have numbers starting with 0".

  • VictorSierraGolf (unregistered)
    well pardner, that don't look like no number I've ever seen, here's the biggest one I got,

    Why did I read it in Georg Carlins voice?

  • foo (unregistered) in reply to pitchingchris
    pitchingchris:
    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.

    Wow, you managed to get trolled even though I didn't mean to (note the smiley).

  • validus (unregistered)

    No, dude. What you should have learned from that is that your suck as a coder, and that your logic is not quite there yet.

    I'm referring to casting that phone number value to numeric. If you're casting to this and that solely on the look of the value, that's where you're making a mistake. Add a metadata value that will mean the type, and cast based on that.

  • (cs)

    Perl is also quite interesting with large integers:

    #! /usr/bin/perl

    printf "%d\n", 2 ** 62; #4611686018427387904 printf "%d\n", 2 ** 63; #-9223372036854775808 printf "%d\n", 2 ** 64; #-1

  • DidThisOnce (unregistered)

    Reminds me of something I did once.

    The purpose of the code was to read a barcode badge that contained a persons SSN and alert them to pending notices. Simple enough, but we needed to provide keyboard input because they may not have their badges just yet.

    I thought I'd take a shortcut and just do a validation check by casting to a number and displaying an error if it didn't match. Well, it also happens that the barcodes append a number to the end depending on what department you work for (1 digit). Making the barcode numbers 10 digits long.

    Well this all worked for testing, because every test badge we had used SSNs printed for people in PA (SSNs start with 1 most of the time). The first time a contractor arrived from out of state (about 1 day after this went live), he had an SSN / badge that started with a 3. Broke everything good.

    Now we have real input validation!

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to John Winters

    google for 214-748-3647 eyes get big

    John Winters:
    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's when they do that about credit card numbers that bugs me, but I'm sure the credit card companies are super strict about not massaging those numbers or something like that.

    Also, TRWTFIPHP

  • (cs)

    This isn't the worst I've seen. Here's how MS SQL Server guesses data types in imported Excel spreadsheets:

    • Look at the top 20-ish rows.
    • Is any single one of them numeric?
    • If so, MUST BE A NUMBER!

    Thankfully, SQL Server does care about cell formatting (unlike Access, another program that has WTF Excel importing - you'd think Office would have pretty good compatibility with itself, but you'd be wrong). So if you format the column as Text, it won't type-guess.

    But as an added bonus, it silently fails to import numeric values into fields set up as varchars. And there's no option to tell it to explicitly cast numbers to strings either. So you get to import the data once to get all of the numeric employee IDs, import it again to get the non-numeric ones, and then merge them together.

    Edit: To be clear here - I mean that, even if it's from a column that you explicitly state is a string, SQL Server will still insist that "24593" is a number, and will fail to import it, presumably because it converts it from a string to a number, and then wonders why it can't put it into a string field.

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered)

    You know what? After looking over Google results for 214-748-3647, it's obvious that there is some way to game Google to have your search turn up for anything that looks like a phone number. (Not that I hadn't already guessed this from all the crap you get when you type in anything vaguely like an electronic part number.)

    According to the results I get, people all over the country have this number, not just in Dallas! I think I even saw an address from Ontario with this number.

  • (cs) in reply to Spoe
    Spoe:
    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.

    Yeah, C does stupid crap, but it does it quickly, and that makes everything OK! </sarcasm>

  • (cs) in reply to Spoe
    Spoe:
    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; }[/code]

    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.

    That's because C is a low level language, without the concept of exceptions. You use it when you want a low level language, and don't want the computer to do things when you are not looking. If you are coding in C, you'd better know what comes from that addition, or at least check error.

    That is different from PHP. You choose PHP when you must work on a PHP codebase, or when you are insane.

  • Publius (unregistered) in reply to PiisAWheeL
    PiisAWheeL:
    Rick:
    The lesson that I learned more recently is "Don't use XML."
    FTFY.
    +10 irony internets awarded for presenting this advice using an XHTML-based website
  • Harold (unregistered)

    Too late on getting that phone number.

    It was taken in the early 90's by a friend of mine.

    He has going to an asterix box. It all goes to voice mail.

    On occasion he listens and says that some of that is pretty funny. Mostly it is drunks guys who have just hit some crazy max score on the arcade game Golden Tee. They think it is a hoot to call the number and leave a message.

    He should save some of those up and post them.... but that would be too much like work.... :)

  • Max Int (unregistered)

    Hey why are you spreading my phone number around?

  • Todd (unregistered) in reply to Mike
    Mike:
    TRWTF: Languages that hide exceptions and returns random crapola as data. Nice!
    At least C has the excuse of "it's for the efficiency, this way we can do it in just one assembly instruction" (not that it's a very good excuse though, it makes much more sense to make it a compiler option and enable bounds checking by default).
  • Spoe (unregistered) in reply to Mcoder
    Mcoder:
    That's because C is a low level language, without the concept of exceptions. You use it when you want a low level language, and don't want the computer to do things when you are not looking. If you are coding in C, you'd better know what comes from that addition, or at least check error.

    Yet in many situations C sets errno, a rough approximation of an exception, e.g. if using strol(). Not here.

  • Sea Sharp, Waves Hurt (unregistered) in reply to Drtfsxzjkl
    Drtfsxzjkl:
    Akismet's algorithm is (or at least includes): if (post.endsWithURL()) then {is_spam = true}. I've yet to see a single counterexample.
    Truth of the programming tree is under roots of bark skin tantamount to tranquility. Foresight combines food and lack of oxygen to produce decapodic didacticism. Frisky front-facing foibles frame fantastic folly for few friends.

    http://www.slashdot.org/

    Dogs are animals that fear most stammering stealth but can't reproduce exotic beef jerky. Moira is a name that was given to some girl in a story and didn't have any meaning other than the meaning that it had. Candle-lit dinners are dark.

    Evil isn't good.

    What? The water? I can't hear it because the stand of Douglas Fir is rustling in the wind blown by large mountains falling in the sky to the area left of the wood burning farm for sticky bootlaces. I don't know.

    http://www.yahoo.com/

  • Anon (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?

    What the hell kind of sense does that make?

    Welcome to the wonderful world of PHP.

    In the world of PHP, if you ask it to do something stupid that it doesn't understand, it decides that it's better to just do something rather than give you one of those troublesome error messages that stops your program from running. Nobody likes those.

  • Geoff (unregistered) in reply to Spoe

    Well a more useful comparison would be what dose atoi() do when given input to large for an integer. That too appears to be undefined so your point stands.

    Still unlike C which needs to be simple to best meet many of its use cases, PHP is a high level language with a pretty specific target application. I would expect some error handling from its type conversion library functions.

  • steve (unregistered)

    Just ran into something similar.

    Zip codes and social security numbers can start with a zero and look odd when stored as an int.

  • Jay (unregistered) 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.

    That seems rather pointless. If all the numbers start with a zero, then the zero is superfluous and could be left off.

    Well, that said, my electric company has all it's customer account numbers start with the same three digits, I think it's 973 or some such. So when you call and they ask for your account number, if you give a number that DOESN'T start with 973, they know that you're giving them the wrong number so they don't try to use your phone number or social security number or whatever as an account number and maybe screw up someone else's account. Or if a customer has trouble finding their account number on their bill or whatever paperwork, they can say, "Look for a number that starts with 973." Seems like a not-bad idea; I may use it someday.

  • datachick (unregistered)

    If you store ZIPCodes as numbers, you'll lose leading zeros and have to do a bunch of casting/converting/BS to get the right value.

    ProTip: If humans use the word "number" in describing the data, it's never* really a number. VIN, Account Number, Customer Number, etc.

    *close enough to be "never" to be truthy.

  • Jay (unregistered) in reply to Gizzmo
    Gizzmo:
    What, and you didn't notice that 2147483647 is (2^31)-1? Sheesh. :)

    Well, I've been in this busy for 30 years, and I must admit that I didn't immediately recognize it. Sure, if you asked me what the 32 bit int max was, I would have said 2.1 something billion. But seeing it formatted as a phone number, it just didn't occur to me. I can see that if you live in or near a 214 area code, it would be even less likely to leap out.

    Indeed, my first thought when I saw that phone number given was, Wow, shouldn't they have anonymized this, put in a 555 number or something? Otherwise a bunch of idiots are liable to call that number.

  • (cs) in reply to willaien
    willaien:
    Veekun has an excellent article on why PHP is a bad idea for any project of sufficient size to warrant a language be used.

    Veekun's the guy who designed the architecture that Facebook runs on, right?

    No?

  • Jay (unregistered)

    Apparently the poster isn't the only person to have a problem with this magic phone number.

    http://www.24hourplaces.com/search.php?state=AL&city=&category=0&zip=&miles=1&page=1

  • Jay (unregistered) in reply to willaien
    willaien:

    As opposed to projects small enough that you don't need any language at all? I'm not sure what that means. "What language did you write this program in? Java? PHP? Visual Basic?" "No, this was a small project, so I didn't use a language."

    But this is just a short comment, so instead of writing it in English or Spanish or French, I probably should have just written it without using a language.

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

    That seems rather pointless. If all the numbers start with a zero, then the zero is superfluous and could be left off.

    It could … if you set up the system so that everyone in your country is in the same area code, anyway. It's the area code that starts with a 0, to allow the phone system to differentiate between local and long-distance calls.

  • Ken Snyder (unregistered)

    Yes phone numbers are not numbers at all. You sometimes need extension numbers. Or maybe a + to indicate the first part is an international calling code.

    If you are dealing with international phone numbers you will never be able to insert dashes programmatically. There are too many rules and they change too often. In South Korea, for example, the number of digits in the area code varies and the remaining part of the phone number may be 7 or 8 digits. By convention they split it up into 3 and 4 or 4 and 4.

  • yoda (unregistered)

    TRWTF is using PHP for anything moderately complex.

  • Jay (unregistered) in reply to ¯\(°_o)/¯ I DUNNO LOL
    ¯\(°_o)/¯ I DUNNO LOL:
    John Winters:
    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's when they do that about credit card numbers that bugs me, but I'm sure the credit card companies are super strict about not massaging those numbers or something like that.

    I agree. How tough would it be to strip out spaces and hyphens so the user can enter his phone number or credit card number the way he is used to seeing it?

    Back in the early days of computers (I don't think so much today), many people would type the letter oh instead of zero and the letter el instead of one, which of course would then screw up numeric inputs. Manuals would routinely lecture users not to do this. Just because it looks right on a typewriter, it doesn't work on the computer, etc.

    My boss years ago came up with a simple solution: He modified our number input function to interpret letter oh as a zero and letter el as a one. When I saw it I thought, zounds, what a simple solution! Instead of lecturing users over and over about the same error, just fix it for them!

  • (cs)

    PHP can not be use for serious projects.

  • Anon (unregistered) in reply to Jay
    Jay:
    My boss years ago came up with a simple solution: He modified our number input function to interpret letter oh as a zero and letter el as a one. When I saw it I thought, zounds, what a simple solution! Instead of lecturing users over and over about the same error, just fix it for them!

    Great. So they can complacent on your application, then go entering invalid data in all the other applications.

    I would rather use an input mask so they can mash the 0h and el keys all they want but they will not pass validation because they have not typed enough characters. Eventually maybe they will get a clue and find the 0 and 1 keys actually show up on screen.

  • foo (unregistered) in reply to Spoe
    Spoe:
    Mcoder:
    That's because C is a low level language, without the concept of exceptions. You use it when you want a low level language, and don't want the computer to do things when you are not looking. If you are coding in C, you'd better know what comes from that addition, or at least check error.

    Yet in many situations C sets errno, a rough approximation of an exception, e.g. if using strol(). Not here.

    C != libc
  • foo (unregistered) in reply to Jay
    Jay:
    ¯\(°_o)/¯ I DUNNO LOL:
    John Winters:
    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's when they do that about credit card numbers that bugs me, but I'm sure the credit card companies are super strict about not massaging those numbers or something like that.

    I agree. How tough would it be to strip out spaces and hyphens so the user can enter his phone number or credit card number the way he is used to seeing it?

    Back in the early days of computers (I don't think so much today), many people would type the letter oh instead of zero and the letter el instead of one, which of course would then screw up numeric inputs. Manuals would routinely lecture users not to do this. Just because it looks right on a typewriter, it doesn't work on the computer, etc.

    My boss years ago came up with a simple solution: He modified our number input function to interpret letter oh as a zero and letter el as a one. When I saw it I thought, zounds, what a simple solution! Instead of lecturing users over and over about the same error, just fix it for them!

    Until a Brit from Oldham (OL) tried to enter his postcode ...
  • bruno (unregistered) in reply to Cbuttius

    Also, you could use alpha-numeric in phone number for aliases 1-800-WTF-WTF1

  • lopacsqas (unregistered)

    Dude, next time treat phone number as strings, why in hell would you treat differently.

    Noob mistake.. i hope you have learn!

  • David C. (unregistered) in reply to Spoe
    Spoe:
    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

    I inlined your correction in the above quote...

    What you're seeing here is a bunch of quirks of the C language and what compilers are allowed to do.

    First off, when I compile this, I get a warning for the INT_MAX+1 expression. So any developer should immediately know something's wrong here.

    The reason for the seemingly contradictory answers is that the compiler isn't actually doing any arithmetic, but is shortcutting the expression, generating constants.

    In the case of the first expression ((INT_MAX+1) > INT_MAX), the compiler knows that you've generated an overflow (producing the warning.) It also knows that on the x86 platform, INT_MAX+1 is INT_MIN. So the comparison returns false. The generated code passes a 0 constant to printf.

    In the case of the second expression (in the function foo), it sees the expression ((x+1)>x), which is true for all values of x other than INT_MAX. Since INT_MAX+1 is an implementation-defined expression, it can optimize the whole expression to a constant. The generated code passes a 1 constant to printf.

    Some interesting observations (in playing with this):

    1: If you change the parameter to foo (x) to (volatile int x) then the compiler will make no attempt to optimize the expression. It will do the addition, the result will wrap to INT_MIN, and the function will return 0.

    2: If you replace the expression INT_MAX+1 with the result (2147483648), then the compiler will replace the int constant with a long constant, eliminating the warning and causing the constant 1 to be passed to printf, because there's no more overflow condition. (explicitly Casting INT_MAX to long will do the same thing.)

  • (cs)

    I'd hate to be the guy in Dallas trying to start up a business placing guard animals, only to discover the alternative significance of 714-PIT-DOGS.

  • (cs)

    I pity the person (according to a quick search: Wil Stuart) in the Dallas area who actually HAS the number (214)748-3647. Someone else mentioned that he has a recorder on the number. So, let's all try it (not really, he doesn't need the attention!).

    Before (like before 1995) when ALL area codes had a 1 or a 0 as the middle digit, you COULD actually encode a US/Canada phone number as a 32 bit int. Take the middle digit of the area code as the most significant digit and then use the next 9 digits. Some things actually used this technique. Now with the proliferation of things like cell phones (which chew up LOTS of phone numbers) we have zads of area codes, so it doesn't work any more. In this encoding scheme, the phone number would be encoded as: 1247483647. Trivia: When AT&T first proposed things like area codes back in the 1940's, they estimated that the scheme with area codes with 1 or 0 as the middle digit would last until around 2000, considering that they were estimating 50 years in the future, being off by 10% (5 years) was a pretty good prediction.

  • John Hensley (unregistered)

    ANOTHER integer overflow WTF, don't the editors ever get tired of them? Anyone who can't immediately recognize an integer limit value shouldn't be reading this site anyway.

  • Anon (unregistered)

    All I learned from this is that your code is shit.

    And there's probably 10 submissions that weren't posted here about how you were casting the number and it broke that stupid language spectacularly.

  • Meep (unregistered) in reply to Drtfsxzjkl
    Drtfsxzjkl:
    willaien:
    Akismet seems to think I'm spamming up the joint, so adding a bit of text below the URL.
    Akismet's algorithm is (or at least includes): if (post.endsWithURL()) then {is_spam = true}. I've yet to see a single counterexample.

    Well, any actual comment spam kinda has to have a link to work. And a lot of comment spam tends to be drawn from other comments, with a link thrown in. It's probably a pretty effective heuristic.

  • David F. Skoll (unregistered) in reply to Spoe

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

    Experienced programmers realize that C is a glorified assembler language, so they expect it to do things like this. A high-level [sic] language like PHP should offer more protection.

  • (cs) in reply to Mcoder
    Mcoder:
    That's because C is a low level language, without the concept of exceptions.
    Is C lower-level than any number of 8K BASICs that supported exception handling (known at the time as "error trapping") perfectly well?
  • FAsl iegh (unregistered) in reply to Carl
    Carl:
    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.
    yes indeed it would be - but I'm not sure that this article suggests that would have necessarily been the case - only that that was the first point of investigation.

    (although, TBH I've never worked anywhere where the Dev box is exactly the same as the prod box - partly because people have played with config, partly because the box is often lower spec and partly because people are scared that if they make it too real it might accidentally do real stuff)

Leave a comment on “Confessions: The Phone Number”

Log In or post as a guest

Replying to comment #:

« Return to Article