- 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
Admin
If you redefine _250 how will you specify the 250th parameter in a boost::bind statement?
Admin
Whenever I read these WTFs with enums, the closing braces with semicolons looks even sadder than usual...
};
Admin
Admin
Admin
Sasha motives is wrong, but stumbling upon elagant perfromance technique.
Admin
I have some sympathy for this guy. I dealt with a compiler once that treated the literal 2 strangely when used as an array index.
The following int myArray[]; int a = 2; myArray[a] = 1;
Would yield a => 2 myArray[2] => 1F398A9C (random 4 byte sequence)
Admin
Not much different from what English people did to rest of world two century earlier.
Admin
Umm, someone says, "here's how to format your output padded with the required number of leading zeros" and your reply is "that's unnecessary -- just format your output padded with the required number of leading zeros".
Admin
I don't think the point of the complaint was, "Is it possible to write a program in which you never write a decimal number with leading zeros?" The answer is obviously yes. The complaint was that programmers sometimes don't know or forget that leading zeros cause the number to be interpreted as octal, they do sometimes put leading zeros on a decimal number to make columns line up and that sort of thing, and then the results are confusing. As programmers rarely have a need to express numbers in octal, it would not be surprising if many were unfamiliar with this rule.
i.e. the issue is not that it creates an unsolvable problem, but that the syntax is non-intuitive, perhaps unfamiliar to many, and thus a potential trap for the unwary.
Admin
I don't think you're wrong. Presumably the redundancy argument was about an LCD Display (Liquid Crystal Display Display).
Either that, or a reference to http://thedailywtf.com/Articles/The-cbitmap.aspx (a case of an embedded system without a filesystem that embedded BMP files into the C source files; to the complete confusion of the submitter. Proof that no matter how much you think you know, others might know more than you).
Heck, one could argue the firmware on my camera is embdedded, but it sure interacts with FAT filesystems on SD cards.
Admin
(smug) Yep.
Admin
There may be a lesson in that.
Admin
Admin
Isn't it obvious that the poor sod can't get over the beatings his ancestors received from people, clearly superior at the time?
Admin
I hate those dumber string formatting functions. Lucky c++ has more advance string class.
Admin
No, you are wrong, because the ZIP is not really an number, it must not be treated like number, because it is an identifier. Doctah are correct. Everything else that can have only numbers is numeric and need to be stored in numeric variables or fields.
Admin
If you're that concerned about using an appropriate type, use something with a sufficiently rich type system.
Admin
Not me. I determine which to use based on which one stores in my database better. It takes 2 bytes to represent a zip code as a number and 5 to represent it as a string. It also indexes easier. Idk though, maybe I'm just a whore for efficiency.
Admin
There was once a moderately obscure platform that systematically used <radix><underscore><number> to represent integer literals, so you would write for example 8_377 or 16_FF instead of 0377 or 0xFF. Simple, unambiguous, and supports bases other than 8 and 16.
Of course, it had to go.
Admin
They do realise that absolutes is the way of the Sith.
Leads to the Darks side it does........
Admin
You are obviously correct and probably somebody who knows what the f* he's doing .. They are java programmers, complete total utter noobs who actually believe it'll be so much better if you CALL those digits a string INSIDE the computer ... when in effect that is merely a human view on the subject, which the machine doesn't care about.
FFS . How can two different people even stand behind that failure of an argument I cannot understand ... keep on creating WTF though .. go ahead .. "identifiers" my ass . my unique ID columns are sometimes integers, want me to store those as strings too ??
Admin
Nagesh, Please (not "Plz") read (not "be reading") about Premature Optimisation before making (not "meking") uninformed comments (not "coment") about programming for performance in any language. Don't write rubbish code in a futile attempt to achieve nanoseconds worth of performance improvement.
Admin
enums are the solution to those octal mistakes.
Perfect alignment.
Admin
Sorry, no can tell. That's only revealed on a need to know basis. But I can give you a clue: its hold by the Fnord Fire Circle :P
Admin
TRWTF of course are online forms that require me to enter a ZIP code and refuse to accept "SW1V 3BS" as an answer.
Admin
TRWTF: people continue to fall for Nagesh's tired old schtick.
Admin
Fixed length strings can be stored as integers too. Do you do that as well?
Admin
And that's the way I gotten burned by this. Know TCL script? Well, weakly typed - everything is a string. But hey, they use the same numbering notation as C: leading 0 means octal, leading 0x means hex. Getting into date processing, one gets a string like "110503" which represents YYMMDD, i.e. thr third of May 2011. Now you split the thing into 3 teo digit sections and assign them to variables year, month and day. And you do arithmetics with them - all is fine whilst testing the code. Now guess what happens when you get to the eight of May - or to august in that respect.
expected integer but got "08" (looks like invalid octal number)
Admin
Erm, this code instigates undefined behaviour, does it not? Without the array size, how can the compiler assign apropriate memory for the array? In the case of gcc, the compiler gives an error:
bad_array.c: In function
main': bad_array.c:6: error: array size missing in
myArray'By setting the array size, I get it compiled. If setting the size too low, I'll get a seg-fault. When set apropriately I get the expected result (the value 1).
Assuming the compiler does not complain, what most likely happened was this:
Who knows where myArray[a] pointed to - could be stack, could be heap - modification could have happened by calling the 'printf' you may have used to display its content.
Admin
There is nothing strange about that! Initialize your array with a size bigger than a and it will work properly.
Admin
HAhahahaha! Best comment EVER!
captcha: who cares? grow up.