- 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
Perhaps he should get a job as one of those guys who stands in the middle of a shopping precinct wearing a suit and big glasses, carrying a bunch of badly-printed pamphlets with which he attempts to engage passers-by in conversation. He'd probably be clever enough for that, but not clever enough to divine its pointlessness as an occupation.
Admin
Don't forget:
#define number_base = 13;
or it won't work.
Admin
Admin
The code wasn't originally done in octal. I found out later they were just trying to pretty it up without really thinking about what they were doing.
Admin
Maybe to make them occupy the same number of columns, maybe to match file names which need to appear in the correct order when sorted alphabtically (000-FileName.txt, 001-FileName.txt, ... 999-FileName.txt)... who knows?
Admin
This is an incredibly clever way to get around the
problem.
Admin
For columns - if it's in your code, then use spaces (they're free)...
Let me ask the question again, when in your code do you use preceding 0's (other than to specify Octal)?
Admin
The Hitchhiker's Galaxy is for people who want to cling on to the past and proclaim "Days were always better then!".
Admin
I recall some people I have worked with explaining that in fortran if you passed a number by reference into the parameter of a function, and that function changed the value of the parameter, it would change the value of that number in the program forevermore.
Admin
So, what are the chances that he actually got burned by using magic number 23 instead of MEANINGFULLY_NAMED_CONSTANT?
Admin
This is one of those problems that, when it crops up, should be taken as a sign that you're doing things the wrong way in the first place.
1 is a number. 00001 is a string.
Admin
int numbers[] = { .001 * 1000, .002 * 1000, .003 * 1000, .004 * 1000, .005 * 1000, .006 * 1000, .007 * 1000, .008 * 1000, .009 * 1000, .010 * 1000, . . . };
Admin
00401 is a ZIP code (which happens to be for Pleasantville, New York, the home of Reader's Digest). Excel allows the numeric format 00000 to prevent suppression of leading zeroes if you should happen to require ZIP codes in your data.
Admin
I assume (no being a yank) that Zip codes are always 5 digits, so we can still store it as 401 and pad out the 0s when we need to display.
Pretty sure when we read input we don't make assumptions on format, so leading 0s don't mean diddly squat
Admin
Sometimes they're five digits.
Sometimes they're nine digits with a dash between the fifth and sixth.
Oh, and if you want to send mail to Canada, they're letter-digit-letter-space-digit-letter-digit.
So best to just make it a string and add custom validation based on the country if you want to.
Admin
Admin
Admin
The real WTF is all those stupid fucking programs vomited up by shit-for-brains programmers which are supposedly for the international market where the (mandatory) postcode field allows only digits.
Admin
Number_9; Number_9; Number_9; Number_9;
Admin
For any example I could think of, someone could say "Well, just don't do it that way." And that's fine. But my point is that 0120, for example, has a numerical meaning to non-programmers/beginners that is very different from the programming language's interpretation, and it didn't have to be that way.
Admin
whats wrong with you ppl. Not 1 grammar-nazi correcting 'burned' to 'burnt' !! Shame!
Admin
This is where I'd be sorely tempted to modify the compiler to randomly re-arrange enums with a significant number of number words as identifiers.
After all, if they can get literals wrong, what's to stop them from getting enums wrong too? It would be a highly amusing prank to play.
Admin
Maybe because "burned" and "burnt" are both accepted spellings for the past participle of "burn"? Additionally since the usage of "burned" was in a quotation, it would not be corrected to "burnt" anyway, it would be "burned[sic]", if anything.
Admin
Agreed. I hate these fag frist idiots. They make every comment section start by immediately pissing those with a real sense of humor off. It sure never gets old. Never!
Admin
I find it a little ridiculous that we're still using Latin in English sentences, e.g. "e.g.", "[sic]", "i.e.", "per se", "etc.", etc.
Admin
that reminds me of my first qbasic program
Print hello world
which then changed to
Print hello; world;
and then on the screen 0 0.
next day at the school libary I reread the book and found out I needed to put print "Hello world"
Admin
Admin
You have to admit that's a cool way to justify complexification: Write a bad compiler and then use its deficiencies to justify your complexification.
That's "why" they wrote INTERCAL.
Admin
Don't say that. Someone might confuse this site with twitter or their email account from looking at the article.
Captcha: Ratis. Gratis is free, ratis not.
Admin
If the VALUE of "seven" change... the value of seven should never.... oooh I see what you did there... nice burn.
Admin
Admin
Just taking a different line here. Could the bloviator be referring to the fact that using literals would have made the compiler use 32 bits but the code depended on assuming values to be 16 bits? And hence the usage of enum (evidenced by the max value variable). Though another gotcha here is that if you use a maxval element of 0xffff, the enum is again going use 32 bits. To force it to 16 bits, you need to use 0x7fff
Admin
Constants! Constants?? Fortran!!
<main> CALL SUB (1.0, 2.0) ... <subroutine> SUBROUTINE SUB (A, B) A=2.0 B=7.0 RETURN ENDWorks wonders for generating bugs.
Admin
Admin
That just makes the program crash at runtime, so it's easily tracked down. No big deal.
Admin
...and they'd be right. Even if you were coding in a language where assigning "0001" as an integer value would carry the leading zeros when concatenating with a string, you'd still be putting your formatting logic in a place where it didn't belong.
Admin
So store it as a string? Again, stop and think about what you're doing. If the exact sequence of characters is what's important, not the numerical value, then it's not an integer. It's a string.
Stop hacking, do things the right way, and save yourself a lot of effort.
Admin
Also in his defense, using a leading zero to indicate a different base was a bad idea by the C language people. It clashes with everyone's intuition (learned in elementary school math class) that leading zeroes don't change the meaning of a number.
They should have gone with a different, less loaded convention, like maybe a leading o (e.g. "o755").
Admin
It's not hacking, it's inheriting a system from someone who didn't understand that just because something has digits in it doesn't make it a number.
When I've had the opportunity to train new programmers, I explain that unless you plan on doing math with it, make it a string. Would you subtract one ZIP code from another? Increment a Social Security Number? Divide a credit card number by two?
This is my small and largely ineffective way of trying to make the world a better place for generations of programmers yet unborn.
Admin
Admin
These are the "safe" ones ..
Admin
These are the "safe" ones ..
Admin
How much are we betting he was "burned" by typing in numbers with leading zeros (ie. octal)?
Admin
Admin
Excel also has the biggest ever collection of data/presentation layers mixup / auto destruct failures.
Admin
Admin
int valid_page_numbers[] = { 0000, 0001, 0002, // etc.
Got it now?
Admin
Well yes .. but no If you start storing numeric values as varchar or using them as strings in your application when they can only have numeric values, ... you should probably avoid giving advice ;)
Admin
Admin