- 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
first - 0
Admin
Two possibilities would be (obviously) that either it is causing a cast or - more likely - it was just an indication of plus or minus for the offset that is now removed - in case he needs it again.
Admin
third! And yes, that's what I yell in bed.
Admin
This is actually an old trick; on some old interpreted languages (think Applesoft Basic) with floating point expression issues (spurious resolution problems that went beyond normal resolution issues), a good way to clear up the problem was to force the variable into some arithmetic expression; a = a+ 0 did the trick.
Can't imagine that surviving a high-level optimizer nowadays, though.
Admin
Possibly not a (total, because the result of the min/max is unique) WTF, as -0 < 0 and this could cause non overlapping rectangles appear overlapping using standard checks.
Admin
I have no idea how many variables I have multiplied by one. x*=1; In various languages it has solved a multitude of hurts.
Admin
reminds me of javascript to string conversion: ""+x :P
Admin
I always get min and max mixed up - when I want to set a minimum bound of zero for something, I do this:
foo = Math.Min(foo, 0);
and wonder why my "minimum bound" doesn't work and it acts like a "maximum bound" instead! :P
Admin
Admin
I suppose all you do about it is hope you can go home earlier the next day to scream "FRIST!!11!"? Care to give me your home address?
Admin
x.toString();
;)
Admin
Looks a lot like there used to be constants in there instead of 0. Perhaps whatever reason they were adding and subtracting constants went away, so a developer swapped the constants out for zeroes.
The permanent and more-correct fix would be to remove the line altogether, but perhaps the developer thought he'd be going right back in and changing the constants again?
Is this code any LESS worthless? And yet somehow it seems more appropriate...
Admin
Admin
oh, you mean: (x==null ? "" : x.toString())
somehow ""+x seems simpler...
Admin
Probably it's the easiest way to convert to INT!
Admin
You're halfway there. You've shown the next person that X_OFFSET may occasionally change, and happens to be zero for now.
To finish your fix, just take that special symbol and add it to the other lines, this kinda ties them together in a group to show that they're all part of the same idea:
Admin
Admin
Anyone into a contest for saying
in the most rundabout way?
Bonus points for solutions the compiler can optimize back to
:)
Admin
Admin
Admin
Admin
What if X_OFFSET is negative?
Admin
Perhaps there's a similar block of code immediately above or below this one where the offsets are non-zero and this code was presented in this way to make the similarities more obvious?
Admin
Maybe I'm missing something but to me TRWTF is that a line like:
Is basically the same as Which essentially does nothing.Admin
You're missing something. That's not TRWTF, that's the TOWTF (The Original WTF).
Admin
All joking aside, for older PHP versions it would yield more accurate results to use $value * 1 then intval($value), for a $value big enough. Commenting something like that would be kind'a trivial tho'
Admin
Admin
Admin
Well, this looks like C# to me, and that certainly shouldn't have any effect there. At least, it has to be .NET (Math.Min, shudder), so perhaps it is VB version whatever and it has some obscure ... Nah, can't imagine.
The other thing about this code is the consistent use of "this.". I can't imagine that being necessary, unless this code was automatically translated from some old obscure VB code where the minus and plus zero do have an effect?
Anyway, whoever wrote that -0 < +0 should have his numeric coprocessor checked or stop working with 1-complement machines.
Admin
all the time. Sometimes 0th
Admin
Of course not. He lives in a small community, so he just assumes 'all of them'.
Admin
I prefer self-explanatory to simpler.
being clever < being clear
Admin
'T'o 'b'e 's'u'r'e, 'y'o'u 's'h'o'u'l'd 'p'r'o'b'a'b'l'y 'p'u't 'a'n 'a'p'o's't'r'o'p'h'e 'b'e'f'o'r'e 'e'v'e'r'y 'l'e't't'e'r. 'T'h'a't 'w'a'y 'y'o'u''r'e 'b'o'u'n'd 't'o 'b'e 'r'i'g'h't 's'o'm'e 'o'f 't'h'e 't'i'm'e!
Admin
Admin
(Ten bucks to the first Windows user who can figure out how I did that without compiling code. And no, it wasn't click, paste, click, paste, click, paste, click, paste, click, paste, click, paste, click, paste, click, paste...)
Admin
Casting by accident solves the hurt, but it also leaves a silly looking scar.
Admin
It 'appears' to do nothing. however, we don't see the code for the property setter. Maybe the setter does more than just set a field value. Maybe it has other side effects.
The WTF is that the property setter has (presumably) undocumented side effects that confuse the API consumers.
Admin
Admin
String(x) has the exact same behavior as ""+x but with better readability.
Admin
In Python: print "".join([i + "'" for i in string])
I was trying for a one-liner, maybe there's a better one, though.
No compilation needed. But maybe you did some fancy shell scripting or use an advanced text editor?
Admin
Oops, you said Windows, so it's probably a cmd.exe or notepad trick. I don't know. Can I have ten dollars just for being me?
Admin
I didn't see him mention anything about men - you're making assumptions there!
Admin
Admin
I wanted to write that the code probably evolved from another code dealing with some border around the rect, but such code would have been developed:
a) with negative borders in mind b) by someone that never heard of abs()
So, I guess it is a wtf evolved from a previous wtf...
Admin
For such a short message, where it is unlikely that the need should ever arise again, I would suggest: bruteforce typing.
Admin
Admin
Admin
use Word. Type in the original line and use Find and Replace, more options, Special and replace 'any letter' (^$) with Find What Text (^&) and ' i.e. ^&'
replaces every letter with the same text + '
Admin
oops! apostrophe should be before the ^& to match your example...
Admin
This is one of the stupidest WTF posts ever. There have already been several reasonable explanations for why it could be done. Forgetting to leave a comment explaining something that may not even be worthy of a comment is hardly a WTF.