- 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
It's been a while since I worked in classic ASP, but this looks like it's just straight classic ASP to me. Nothing .NETy about it at all. Perhaps the function was just imported as-is as part of a larger app and maybe the mandate was just to make minimal changes to keep some app running? Classic ASP predates .NET and in the first years, there were no libraries at all for handling these types of security issues.
Not saying the code is a gem, its a pig, but I think that the WTF being predicated upon the fact that there are libraries to handle security concerns may be incorrect, because there weren't any back in the day.
Admin
Won't work in a platform independent manner and can have trouble with various signed integer representations and taking the average in the range of negative numbers.
I remember the old thread. It was orginally posed as an exercise in WTFery; trying to find as contrived a way as possible to implement a common code pattern and hide a subtle bug inside it.
The discussion eventually stumbled into bugs relating to platform (in)dependence and I ended up posting an actual working platform independent solution.
It's a nice little theoretical puzzle, but not something I'd ever want to put into production. ;)
Admin
Some days I don't get VB.
Admin
It has nothing to do with switch statements.
Admin
Just because it's only meant to be used for one-liners doesn't mean it won't end up used for whole documents, at which point it'll take forever to run.
Admin
Fuck this shitty website and fuck the fucking bitches that run it.
Admin
Admin
Admin
The other issue is that if you find something newer and better, chances are, it works differently. They change it to use HtmlEncode and HtmlDecode, and the resulting behavior is different. PHBs will panic:
"There's a line break where the line break should be instead of those crazy characters! Will this display correctly?!?!"
Admin
I think that would work:
int avg(int a, int b) { return (a >> 1) + (b >> 1) + ((a|b) & 0x1); }
Admin
Admin
Admin
Depends on big vs little endian and internal bitwise numerical representation.
Admin
Uh yeah; I kind of never posted that? Evan did. Please learn to quote properly...
Admin
I suppose you think because big/little endian numbers can be seen as being written from left to right/right to left, left/right shifts would depend on that, but no.
Admin
Admin
From the Revised Report on the Algorithmic Language Algol 60: "5.4.4. Values of function designators. For a procedure declaration to define the value of a function designator there must, within the procedure declaration body, occur one or more explicit assignment statements with the procedure identifier in a left part; at least one of these must be executed, and the type associated with the procedure identifier must be declared through the appearance of a type declarator as the very first symbol of the procedure declaration. The last value so assigned is used to continue the evaluation of the expression in which the function designator occurs. Any occurrence of the procedure identifier within the body of the procedure other than in a left part in an assignment statement denotes activation of the procedure." http://www.masswerk.at/algol60/report.htm#5_4_4
Admin
Clbuttic you mean?
Admin
Admin
Admin
Almost the only branch-free version I know of that is guaranteed to work by the standard is return a/2+(a%2+b%2)/2+b/2;. (The standard leaves unspecified whether -3/2 gives -1 or -2, and whether -3%2 gives 1 or -1, but they're required to be consistent: if -3/2 gives -1, then -3%2 gives -1. The above code, I think, works in either case.)
Of course, this was motivated by a real binary search that I was doing, in which the following was my solution:
but that answer is boring. :-)
Admin
Does STATIC_ASSERT get compiled out in release builds like ordinary asserts do?
if yes, you silently get wrong answers when long long is the same size as int
if no, you get crashes when long long is the same size as int, and even though your rules allowed for noisy crashes, you didn't get your binary search working.
(Besides which, the C standard allowed for long long to be shorter than int, though I didn't check to see if they fixed that. The range of integers that work in long long had to be at least as much as the range of integers that work in int, but int could have lots more unused bits so int could be longer than long long.)
Admin
Imagine what happens if HTMLEncode is implemented the same way with reference to HTMLDecode >_<
Admin
Admin
It's amazing how many web and internet applications still can't handle Unicode or UTF-8 codes or even HTML "friendly" codes.
But what's even more WTF is why anything uses Unicode, UTF-8 or "friendly" codes for any of the characters in the standard Extended ASCII character set? There is no reason at all to do so. Nearly every language that uses "english" style characters has every character required present in Extended ASCII. One outlier is Norwegian which has but one or two characters not present in Extended ASCII.
What would be a fun program is one that translates every character in a text file to UTF-8 encoding, with all the leading zeros. Why? To point out how much unnecessary bloat comes from using these encodings for characters that never need it.
Admin
I still resent the fact that C# requires a break even at the very end of the switch statement. That was totally not necessary.
Admin
The meaning of a speedypaper reviews proposal merely suggests a paper containing a table of content; topics and subtopics that will be included later on in the paper. This brief overview will help the readers who are not well-versed with the topic to navigate through the paper effectively and read it to reflect upon their existing knowledge of the subject
Admin
Забота о недвижимости - это забота о приятности. Тепловая обработка фасадов - это не только стильный внешний вид, но и обеспечение сохранения тепла в вашем уголке уюта. Профессионалы, коллектив экспертов, предлагаем вам переделать ваш дом в прекрасное место для жизни. Наши творческие решения - это не просто теплоизоляция, это творческий подхl