News for hackers. Stuff that matters.
Re:Falsehoods Programmers Believe About Phone Numbers by OJFord on Saturday March 19, 2016 @10:03PM (#11321439)
I was scrolling through, feeling largely unsurprised, when:

    14. In Israel, certain advertising numbers start with a *.
Woah! Definitely didn't see that coming; I can certainly imagine my( prior )self storing/passing phone numbers as some integer type.

But along with another user's comment that in Italy, leading zeroes are required, it's clear that (at least in any international application) phone numbers need to be strings.

Re:Falsehoods Programmers Believe About Phone Numbers by noselasd on Saturday March 19, 2016 @10:21PM (#11321481)
If you store phone numbers as integers (you normally should not), remember that leading zeroes are significant. 0123 is not the same as 123. But as integers they normally are (And make sure your parser doesn't parse 0123 as octal).
Re:Falsehoods Programmers Believe About Phone Numbers by NickNameNick on Saturday March 19, 2016 @10:59PM (#11321597)
In general, only store things as integers if it might be meaningful to do math on them.

I saw a database once that stored phone numbers as ints. elsewhere in the software, they tried to take the mean of the wrong column. If the phone numbers had been stored as strings the error would have been obvious. As it was, the error survived in production for a disturbingly long time. The users persisted in thinking the output was meaningful even after the problem was discovered.

Re:Falsehoods Programmers Believe About Phone Numbers by jdavis703 on Saturday March 19, 2016 @10:52PM (#11321574)
Also my U.S. phone number used to be 703-6XX-XXXX (digits omitted for privacy). That's not going to work if you store it as a 32-bit integer (when I was a dumb college student I made a similar mistake, and spent a couple of minutes scratching my head over why my number kept changing to 214-748-3647 every time I saved it to the DB).
Re:Falsehoods Programmers Believe About Phone Numbers by raw_creations on Saturday March 19, 2016 @11:24PM (#11321643)
"Somewhere in Dallas, some poor bastard is wondering why his phone rings off the hook with calls for the Nevada Division of Mental Health & Developmental Services, the Jackson County Florida Chamber of Commerce, a yacht club in New York….." And NASA, apparently http://sbir.gsfc.nasa.gov/award_firm_list/selection_nid/3513...
Re:Falsehoods Programmers Believe About Phone Numbers by mjevans on Sunday March 20, 2016 @04:01AM (#11322204)
It should have strictly warned you about data truncation...

I'd honestly have rather it stored a NULL than that result though.

Re:Falsehoods Programmers Believe About Phone Numbers by jloughry on Sunday March 20, 2016 @12:02PM (#11323386)
Elsewhere I showed [1] that you can store that number in a 32-bit integer if you first swap the leading two digits.

Don't ever do this.

[1] https://news.ycombinator.com/item?id=11323371

Re:Falsehoods Programmers Believe About Phone Numbers by OJFord on Sunday March 20, 2016 @12:07AM (#11321756)
I said 'some integer type' in anticipation of this comment if I'd just said int ;)

Although, the other reason that won't work (which I thought you were going to say) is that it'll end up as -X1XX!

Re:Falsehoods Programmers Believe About Phone Numbers by orionblastar on Sunday March 20, 2016 @01:43AM (#11321958)
I wrote a VB app named Fax Assistant that used Rightfax codes in MS-Word and had to use phone numbers. I stored the numbers as strings/text because sometimes in order to get a fax machine you had to dial a comma and a 2 for some sort of switchbox that shares a voice line.

In St. Louis had 314 and 636 area codes, sonetimes they needed a 1 in front of them based on where you called from. 636 was west county like St. Charles 314 was St. Louis city and North, East, and West county. They used a different area code to make more numbers due to demand.

Re:Falsehoods Programmers Believe About Phone Numbers by dvirsky on Sunday March 20, 2016 @01:49AM (#11321967)
I'm from Israel and I never realized it's unique, funny. I think it started about 15 years ago as way for mobile providers to create unique numbers for their own services like support. And since those are also very short numbers, usually 4 digits, it eventually became sort of a 1-800 replacement (on mobile only AFAIK) because it's easy to memorize.
Re:Falsehoods Programmers Believe About Phone Numbers by ajosh on Sunday March 20, 2016 @02:10AM (#11321994)
US Carriers used to have this and they may still. I have definitely seen signs to call 77 for roadside assistance. I also remember some radio station having a code(star number?) that related. To their frequency.

Edit: Here is a list of emergency numbers. 77 and *999 are on the list for different states. http://www.ou.edu/police/dpsinfo/state-by-state-cellphone-hi...

Re:Falsehoods Programmers Believe About Phone Numbers by Nutmog on Sunday March 20, 2016 @04:53AM (#11322290)
New Zealand has this too with at least one number: *555 for reporting dangerous drivers.