- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
FRIST! and early
Treat all numbers as characters unless you need to do math on them.
Admin
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!
Admin
What, and you didn't notice that 2147483647 is (2^31)-1? Sheesh. :)
Admin
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
Admin
I guess computers in Dallas adopt wild west slang when they type guess and internally monologue to themselves
Admin
Only in Dallas!
Quite literally.
Admin
I must say,I didn't expect this from the first line of the story,good job
Admin
I live in the 989!!
Admin
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!
Admin
As the first commenter alluded to isn't the real WTF here using numbers to store telephone numbers?
Admin
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."
Admin
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.
Admin
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.
Admin
I feel sorry for whoever has that number. I wonder if his name is Max?
Admin
I did read the whole article first, but always felt that simply posting "FRIST" was a bit inane (some would say insane).
Admin
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.
Admin
you do realize that in php, all integers are signed, hence the one missing bit?
Admin
TRWTF: Languages that hide exceptions and returns random crapola as data. Nice!
Admin
FTFY
Admin
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.
Admin
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?
Admin
Let's see, TRWTFs are:
Admin
Did anyone try calling the number? If it was available, I'd grab it. I wonder how many calls they get for this reason...
Admin
I assume you mean PHONE numbers, otherwise this is just silly.
Admin
The real WTF is a 32bit server.
Admin
Tooooo funny! +2^31
Admin
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...!
Admin
Admin
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.
Admin
Admin
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.
Admin
[Insert mandatory generic anti-PHP rant here]
Admin
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:
Captcah: saepius - a very wise comment.
Admin
It's not often that people post WTF's that they're resposible for here...
Admin
You don't have numeric postal codes, numeric identification (Social Security) codes, numeric part numbers ... ?
Admin
Admin
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.
Admin
Congratulations on being the frist person to report your OWN WTF!!
Admin
A dubstep joke on TDWTF! How modern!
Admin
Its not the US numbering system at fault, its the idiot who tried to put it a phone number into an int.
Admin
2,147,483,647th (so not frist ey)
Admin
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.
Admin
Sorry, the number you have called has been changed.
Please redial 9223372036854775807
Admin
Yep. Much like many overflow conditions in C, e.g.:
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.
Admin
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.
Admin
Correction: 0 1
Admin
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.
Admin
Started at a new job. They are using PHP. Realised I'm not going to learn anything here.
Admin
Of course. I think they would look, or see their avatars as, a little like Yosemite Sam. Ooohhh that rackin, frackin PHP ...
Admin
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.