| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Next » |
|
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.
|
|
third! And yes, that's what I yell in bed.
|
|
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. |
|
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.
|
|
I have no idea how many variables I have multiplied by one.
x*=1; In various languages it has solved a multitude of hurts. |
|
reminds me of javascript to string conversion: ""+x :P
|
|
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 |
Re: Math.Min(x, x - 0) = ?
2008-10-22 08:23
•
by
FunnyChauvinist
(unregistered)
|
Despite actually being fifth... the first two must usually be pretty quiet about it. |
That's interesting! Your wife have some fun before you get home and you know it? 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? |
Re: Math.Min(x, x - 0) = ?
2008-10-22 08:25
•
by
Chris
(unregistered)
|
x.toString(); ;) |
|
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...
|
So when you get home, you actually know the number of men your wife has been with previously? How exactly? You count them? |
Re: Math.Min(x, x - 0) = ?
2008-10-22 08:37
•
by
javabrain
(unregistered)
|
oh, you mean: (x==null ? "" : x.toString()) somehow ""+x seems simpler... |
|
Probably it's the easiest way to convert to INT!
|
Re: Math.Min(x, x - 0) = ?
2008-10-22 08:41
•
by
Calm Mint
(unregistered)
|
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:
|
Re: Math.Min(x, x - 0) = ?
2008-10-22 08:43
•
by
secundum
(unregistered)
|
Would'nt that return the string "null" when x is null? |
Re: Math.Min(x, x - 0) = ?
2008-10-22 08:43
•
by
Zeal_
(unregistered)
|
Anyone into a contest for saying
in the most rundabout way? Bonus points for solutions the compiler can optimize back to
:) |
Not if x is null... |
I beg to differ. The *correct* action, regardless of whatever change you want to make to the code, is to COMMENT the damned thing so that future maintainers will understand why you're doing something so unobvious. |
Re: Math.Min(x, x - 0) = ?
2008-10-22 08:48
•
by
SMB
(unregistered)
|
No, it would ont ;-) |
Re: Math.Min(x, x - 0) = ?
2008-10-22 08:48
•
by
Visage
(unregistered)
|
|
What if X_OFFSET is negative?
|
|
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?
|
|
Maybe I'm missing something but to me TRWTF is that a line like:
this.rect.X1 = Math.Min(this.rect.X1, this.rect.X1 - 0);Is basically the same as this.rect.X1 = this.rect.X1;Which essentially does nothing. |
You're missing something. That's not TRWTF, that's the TOWTF (The Original WTF). |
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:06
•
by
FragFrog
(unregistered)
|
Tsk, don't you know that honesty is the basis for any good relationship? Naturally she would tell him! 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' |
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:07
•
by
Sigh
(unregistered)
|
Time for another le's'son on apo'strophe's. You put them before every "'s" and 'sprinkle them rando'mly wherever el'se you think they might fit. They do'nt actually mean anything, 'so it do'e''s'nt really matter e'xactly where they go. |
This wouldn't work if X_OFFSET is negative. |
|
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. |
all the time. Sometimes 0th |
Of course not. He lives in a small community, so he just assumes 'all of them'. |
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:16
•
by
sadwings
(unregistered)
|
I prefer self-explanatory to simpler. being clever < being clear |
|
'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!
|
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:21
•
by
weirded verber
(unregistered)
|
|
|
(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...)
|
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:22
•
by
halber_mensch
|
Casting by accident solves the hurt, but it also leaves a silly looking scar. |
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. |
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:31
•
by
Old Coder
(unregistered)
|
In that case, what you need is: rect.X1 = min(rect.X1, rect.X1 - abs(X_OFFSET)); |
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:31
•
by
infamous_blah
(unregistered)
|
String(x) has the exact same behavior as ""+x but with better readability. |
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:32
•
by
return of the spelling nazi
(unregistered)
|
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? |
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:34
•
by
return of the spelling nazi
(unregistered)
|
|
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?
|
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:37
•
by
JoJo
(unregistered)
|
I didn't see him mention anything about men - you're making assumptions there! |
I was going to guess by typing it, since it wouldn't take long (though I'm not a Windows user so I guess I'm not eligible for the ten bucks anyway.) I am still trying to figure out why anyone would do it by clicking and pasting. |
|
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... |
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:39
•
by
Typing
(unregistered)
|
|
For such a short message, where it is unlikely that the need should ever arise again, I would suggest: bruteforce typing.
|
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:40
•
by
Playit Safe
(unregistered)
|
I'm running on a virtual machine, so here's your virtual ten bucks. (And, no, I didn't say I'm using Windows.) |
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:43
•
by
Playit Safe
(unregistered)
|
'A'a'h 'y'e's, 'b'r'u't'e 'f'o'r'c'e 't'y'p'i'n'g. 'A'n 'e'l'e'g'a'n't 's'o'l'u't'i'o'n 'f'o'r 't'h'o's'e 'o'n'e-'o'f'f 'r'e'q'u'e's't's 't'h'a't 'w'i'l'l 'n'e'v'e'r 'e'v'e'r 'c'o'm'e 'u'p 'a'g'a'i'n. |
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:43
•
by
JoJo
(unregistered)
|
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 + ' |
Re: Math.Min(x, x - 0) = ?
2008-10-22 09:44
•
by
JoJo
(unregistered)
|
oops! apostrophe should be before the ^& to match your example... |
|
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.
|
| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Next » |