- 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
The real WTF is the tripple post....
Admin
I competed in NWERC last sunday... See: http://www.csc.kth.se/contest/nwerc/2006/
The judge's solutions were posted today... I saw the following line in the code:
int INF=99999999
Admin
Defining infinity as a large but finite number is possibly the least wtfey thing there. It seems quite reasonable that you might be modelling some situtation where once a value gets large enough, it might as well be infinite, or that you might want to approximate an infinite process, e.g. a series summation or an iteration, by a finite one.
Admin
Nikita Zhuk is definitely a "he", not "she"
Admin
I would have opted for "DrStrangelove", but I guess "DickBagMcButtMunch" works too..... But I can't even imagine writing DickBagMcButtMunch in code, Even though I consider myself creative......
rob
Captcha = random, as in this programmer
Admin
Exactly right. The SCPI standard (Standard Commands for Programmable Instruments) used in the test and measurement industry defines infinity as 9.9E37. To quote the standard:
Admin
I know absolutely no Chinese, but my research says:
So the function translates to:
Obviously just testing out the language - a HelloWorld sort of thing.
Admin
Don't ever trust your libraries. Common paranoia or defensive programming taken to the extreme?
Admin
Maybe both of those were slightly "creative" ways to "temporarily" comment out the block/rest of the function? Perhaps the JavaScript one already had /* */ comments, so the programmer couldn't have used those (since they don't nest), and maybe that SQL dialect didn't have block comments at all - and both programmers were too lazy to figure out how to make their editors add end-of-line comments to each line (that's not much of an excuse with the SQL one, since it's so short, but that's hardly the worst thing that's ever been on this site).
In that case, the Real WTF is that they didn't use the infinities built into IEEE 754 in the first place.... (Well, OK, maybe they wanted to support systems that don't implement the full IEEE spec.)
Admin
Based on what? That you are Nikita Zhuk? I know two Nikitas and they are both female.
Admin
How would you quantify an infinite value in a finite system? The best you can do is approximate it.
Admin
Ehl. Oh. Ehl.
Admin
Not a WTF at all. Let say you are writing a simple router or something, you need some value that is agreed as "infinite" that can be counted up to for the max delay (that is smaller than the max of whatever data type you are using). Without the rest of the code it's hard to say it is a wtf when it is out of context. The one after baffles me though.. I can't think of a single time when I'd want ZERO to be -1.
Admin
Perhaps they actually have a greater understanding, having prematurely grasped the concept of purely functional code?
Admin
I occasionally find myself adding "if (true) return;" to Java code I'm debugging in order to shortcut over the remainder of the method. In most other languages, I'd just write the equivalent of "return;", but Java, being its tiresome self, knows better than to let me have unreachable code in a method body without throwing a fatal compilation error.
Not that Sun's "javac" would be clever enough to recognize that "if (true)" is, in effect, an unconditional branch, too. Hmm, maybe the original author of the quoted code did have a smarter "javac" implementation than Sun's... but then, debug code like this getting into production is just as much a WTF.
(First post here. I almost daren't press "Post" lest the "hotdog" in the captcha eat my formatting.)
Admin
From the days of yore, when readers of gaming magazines were usually able to code...
That said, just last weekend I came across a cheap accounting tool that, in the print-out for the installation procedure, explained what to change a certain line of install.bat to, since they'd made a typo in one of the batch commands.
In both cases, the one-line fix didn't merit the cost for distributing a new version. Thank goodness for the internet...
Admin
??? is a Russian surname, and ?????? is a male name in Russia.
Admin
So, in Russia it's not a unisex name.
Admin
This was probably intended as an alternative to commenting out the rest of the method. Java normally refuses to compile code that has blocks which can never be reached, so "return;", "if (true) return;", and even "if (0 == 0) return;" would not have worked. You have to trick the compiler into thinking that it might be possible to skip the return. You might want to do this if the code below couldn't be commented because it had /* */ comments in it already, or if you wanted the compiler to continue to typecheck the code even though it was not being used.
Of course, code like this should never be checked in to source control; just used for temporary testing.
Captcha: wtf
Admin
Using "if (true) return;" is possible in Java (I use it sometimes myself) because the compiler does not check for constant expressions. However, my Java IDE's (IntelliJ IDEA) code inspections do give a warning about it, the same they do for "1 + 2 == 3" etc., so maybe the writer of that code wanted to avoid the warning by using an overly complicated expression.
Admin
Admin
Yeah, could well be, good point.
That's deliberately allowed, since "if (constant_expression)" the Java way of doing conditional compilation. On the other hand, it does seem a bit silly to allow literal true or false, once you've decided to be picky about unreachable code, since the point would be to use static final variables so you can change them more easily. On the other other hand, adding special cases like that would just make the language more complicated.
On the subject of smarter Java compilers: the exact reachability rules are defined in the language spec, to preserve the portability of the code - if it works in one implementation, it's supposed to work in any other, at compile time as well as runtime.
Admin
How would you quantify zero in a finite system? Assuming there's always two halves of any finite value
Admin
I cannot find much of a wtf here. Maybe it should better say IF RG<1 THEN RG=1. Really, preventing div by zero is so often done in a "lets use the smallest value near to 0 that makes sense" way, that even if it is wrong to do so (often enough its not) is not a wtf anymore.
But some of the others taught me to not drink while reading this site. Anyone knows how to get coke out of a laptops tft and keyboard?
Admin
Not necessarily. Zhuk is also an Indian last name. Nikita Zhuk is a very likely name for a female from India =)
Admin
Maybe this page, which conveniently belongs to a Nikita Zhuk involved in comp sci (a likely assumption for anyone related to TDWTF) and includes a picture of said Nikita Zhuk will clear up the specifics of this particular Nikita Zhuk:
http://www.cs.helsinki.fi/u/nzhuk/
Of course, someone will have to email Nikita Zhuk to see if we have found the right one.
Admin
That guy really should get the points for that question.
Admin
That would make Khrushchev about the ugliest chick in history.
Admin
And the whole shoe-pounding thing would be a bit ridiculous with a patent leather pump...
Admin
The same way you write infinity in a finite amount of time, make a special symbol for it.
Admin
Screw it, the captcha blocks it all in a few seconds. Anyone know the problem? FF for life.
Admin
WTF?!??! That is the biggest wtf so far. Assuming your not being sarcastic
Admin
I'd approximate it with INT_MAX. Write out the value if I had to. At least that way you can't have a number bigger than infinity.
Admin
The Rand() question isn't really a WTF: all they wanted to do was seed Rand() before they call it, so that whatever seed will always map to a specific sequence of numbers from Rand(). The WTF is that there are "experts" on expert exchange who couldn't grasp that.
PS. Sorry if there are like 3 posts saying this exact same thing, but community server seems to be fucked up again, it keeps redirecting me to search whenever I quote-reply to something... Why does anyone bother with this software?
Admin
Indeed; the WTF for me is that I have to click on the comments link twice to get to the comments; the first time it just sits there for a day and a half; then when I click it again, it goes instantly.
WTF indeed.
Admin
[/QUOTE]
Translation (programmer names omitted):
void calculate (int hi_there)
{
int meaning = 0
//meaning = 3 /* erased by .. */
meaning = 3
return
}
...this looks like someone coding in Java for the first time or is trying out something, and is a function that does nothing (after all, it returns nothing despite it being void - god knows why it doesn't generate a compiler error).
[QUOTE]existingCustomerForm.setError(Boolean.FALSE.booleanValue());[/QUOTE]
Well, he should be right at home with Visual Studio 2005 at least - you'd be suprised at the number of things you'd need these long lines of declarations for. Heck, you have to import namespace to get to use Booleans and Nulls in VS2005, otherwise you type something like the above. >_>
[QUOTE]
[QUOTE]
It's official folks. Micheal Bolton is a closet programmer.
Oh, wait. <_<
Admin
Hehe... yeah Elton John confused that whole issue when he made a song called 'Nikita' and then filmed the video with a very hot blonde woman. But doesn't everybody know that Elton John is gay? Clearly the song was about a man. Also, Kruschev was a 'Nikita', and he's definitely a man.
Admin
INT_MAX may not always be the best value. I have to say I don't really concider this as a WTF, even though I made the first post here.
Let's say you have to calculate the minimum path from one point to another. You could just do:
pathlen = current_path + some_other_path;
if(pathlen < oldpathlen)
oldpathlen = pathlen;
This way you don't have to check for overflows and still just abuse infinity as being a valid value which will be forgotten because adding something to it will never make it lower than any value in the matrix.Admin
It is not a wtf. As you may read just under the headline this whole post is about "fun-but-not-necessarily-bad code". It is not bad code, but I still thing it belongs there, because it is funny.
Admin
Admin
Oh hells yea, that rnd() issue was on side bar once, and it actually stirred up discussion. Unbelievable
http://thedailywtf.com/forums/thread/98836.aspx
Admin
Admin
Hoorah for MS Freecell, the game that actually allows you to set your seed!
Admin
void ChuckNorris(){
for(int i=INFINITE; i!=0 ; i+=ZERO){
if( 0==ZERO) break;
}
}
Admin
You never know, after spending 3 million years in suspended animation, they might go thru a time hole and end up on an Earth where time goes reverse. Enterprisey future proofness !
Admin
I'm currently writing an app that, put simply, simulates an electrical diagram. I have almost the exact same "#define INFINITE 10000" line, except I defined it as 1M. Put simply, the number represents a resistance and is dropped into a matrix to calculate the voltage at a node. With a high enough resistance, no electricity goes through the node, due to the other nodes having a resistance of around 10 ohms. 1,000,000 is a high enough number to effectively take the node out of the calculations, but not high enough (>= ~ 1*10^9) to screw up the floating point math so much that the rest of the numbers get thrown off (1000000000000000000+123.456789 = 1000000000000000100).
If I actually were to use the language's built in "INFINITY", I would get errors all over the place when I do "Infinity/Infinity" math (I want 1, but get an error). Also, I actually need the extra numbers to be in the matrix, ie I need the number 1,000,015 to have the 15 in it, which Infinity would just drop.
Admin
That is by far my favorite one.
Brandon strapped on his seatbelt and braced himself. He was prepared for return ...
Admin
Translation (programmer names omitted):
void calculate (int hi_there)
{
int meaning = 0
//meaning = 3 /* erased by .. */
meaning = 3
return
}
...this looks like someone coding in Java for the first time or is trying out something, and is a function that does nothing (after all, it returns nothing despite it being void - god knows why it doesn't generate a compiler error).
Both Java and C/C++ allow return in a void function, even when it's pointless like it is here. It just has to be an empty return. (Reasons for doing it are about the same as using break in a loop.) Though, in the case, the return isn't necessary since void functions also allow falling off...
Except afaik you can configure the compiler to automatically import System and whatever else you need (Microsoft.VisualBasic for VB.NET, for example). It's a good idea to do it in the file though - you generally can only put so much on a commandline.
Admin
F(*&($&#@#^$! forum software
I love the Rnd() WTF... they do say any monkey can write ASP... I guess that Monkey doesn't know that though.
That's when your buddy says RTFM and you write a post to a forum asking what it means... and some one else says STFW and you ask your buddy what it means.
Sigh... why does this site always look so familiar?
Admin
Now this is a real wtf.
Does anyone think that they can come up with an algorithm that will convert names to 'proper' case? My name has a capital letter part-way through, but there are some branches of the family that spell it with a lower-case letter (the split happened somewhere in the early 1600's). There are many other cases, especialy when people have moved to another country and have converted to the 'proper' spelling for that country, but others have maintained the original spellings (think about names that start with 'van der' or Vander'.