- 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
GCC is an advantage? I thought it was a steaming pile of crap.
I'm totally looking forward to seeing LLVM/Clang completed and hope that everyone will abadon GCC the moment it's released.
Admin
Because I've been corrected properly (I believed it didn't work for 1, but of course it was 0 and less obviously), and have nothing intelligent to say all I can say is... F*ck you.
Admin
Because it still doesn't exist in some problem spaces. Like certain compilers for embedded processors. sigh Sometimes you feel lucky if the compiler even accepts //-style comments.
Admin
I dig on the recursion, but ... uh ... exactly what types does your function accept and return ?
Admin
Admin
So is there going to be a daily WTF article about a certain website that thought it'd be a good idea to have audio-narrated code?
Admin
I would need to double check the exact wording in the specs, but the semantics of C bitwise operators are defined in terms of two's complement, regardless of the underlying architecture.
Admin
I suspect Visual C++ is never going to support C99 either; the level of customer demand for it is probably so low MS can safely ignore it. I think it supports C89/C90 and that's about it.
I'd actually be kind of curious to know how many people are using Visual C++ to write C.
Admin
Admin
[quote user="anon"] // party like it's c99
#include <stdbool.h> [/quote]
Seriously. C99 was ratified eleven years ago. Why do people pretend it doesn't exist?[/quote]
Maybe so, but K&R haven't written a third edition of their book describing it. So, maybe it doesn't exist!
Admin
sizzle
Your function will return TRUE only if x==0.
Captcha "incassum": incassum wrong, I plead the fifth.
Admin
1.) Check Size 2.) ????? 3.) Profit!
Admin
Admin
Well, the standard exists, but no compilers do.
Captcha "modo": Quasi-state
Admin
So, until Clang is completed, which of the available compilers are better w.r.t. optimization?
ICC? Maybe, but it is playing unfair on non-Intel CPUs, and it doesn't run on non x86/64 CPUs. MSVC? Lol. They don't even use expression templates for valarray in their stdlibc++. And it doesn't run on non x86/64 CPUs. And their inline assembler is crap and non-existant on x64. The only thing it is good for is debugging, but then comes Nokia again who have quite mature gdb-integration.
So that there won't be competition anymore. Applause for oxyd.oh why can't I stop posting replies to obviously ignorant trolls
Admin
1 == 1 & -1 (001 == 001 & 111) 001 == 001 = true 2 == 2 & -2 (010 == 010 & 110) 010 == 010 = true
What's the problem?
catpch nisl: That just sounds awesome ;)
Admin
captch dignissim : an obsession with digg.com
Admin
Admin
Admin
Admin
Even though this is not the most efficient solution (by any stretch of the imagination), I've always been a sucker for recursion and bitwise operators:
Admin
arggh! You are correct.
I concede as gracefully as possible ( given that I was all trying to point out mistakes that weren't actually there. )
My brain was working in C.
(what? did nobody like the for-loop/bitshift solution?)
Admin
C doesn't specify two's complement representation for signed integers. But like assuming A to Z are contiguous, most of the time it's safe.
Admin
Admin
Speaking of gcc, I got to learn about fun gcc quirks recently. sigh Apparently there are some subtle floating-point handling issues - which is unfortunate, as code I use uses floats to some extent (and in some cases, doubles).
Admin
There is a faint sizzling sound:
Aside from that it's not bad.
Admin
You are wrong, you'd better plead now.
four-bit word:
Try x == 1 -x == -1 == 0000 - 0001 == 1111 x & -x == 0001 & 1111 == 0001 == x TRUE!
Try x == 2 -x == -2 == 0000 - 0010 == 1110 x & -x == 0010 & 1110 == 0010 == x TRUE!
Try x == 3 -x == -3 == 0000 - 0011 == 1101 x & -x == 0011 & 1101 == 0001 != x FALSE!
etc.
But it is still broken if x == 0.
Watch out for that "only if". "X only if Y" is equivalent to "if X then Y". You probably meant "returns TRUE ** if x == 0" <- no "only" at the **
Admin
Change? You want us to change? Really? Never. C is C is C, no changes allowed! C99exist=0;
Admin
Admin
Admin
The accent still gives me a headache, but the audio was brilliant!
Return i-n-t?
However it's a bit difficult to understand from the audio what the code actually was doing - why did they omit this bit: /*
============= */
and the braces?
Maybe the narrator could also learn to colour-code the text for clarity?
Admin
This must be the saddest comment thread EVER.
The code mode likely does what it should albeit not really clever nor named properly, as opposed from 99% of the "corrections" among the comments.
Now, I'll wait for the next salmiyuck-post instead or, go look at the next wft-question from some lame indian coder on stackoverflow instead. Show me the codez... dude.
Admin
TRWTF is people who think
is cryptic. They really do hand out degrees to anyone these days.Admin
That is very true :)
Admin
Admin
It was actually written with the assumption that your arch did two's compliment - in fact it relies on it.
The first one is a bug, of course.
Admin
well, like most WTFs it was cruft from the iterative process of creation. ;-)
as far as the check, I assume that x already has to be less-than INT_MAX, so ....
totally dignissim (captcha) the
Admin
Or was it just my elementary school teachers who got all strict about "you only say 'and' in a number where you would put the decimal separator, and your answer is wrong if you mess it up," way back when?
Admin
Obviously not a WTF. Clearly they don't have images in infinitely large sizes. Clearly it's C, which lacks a boolean type. Clearly it's not clear that he wants a boolean anyway.
Admin
Two to the power negative infinity is zero.
Admin
Admin
Half of these comments make my eyes bleed.
Admin
These comments prove beyond a shadow of a doubt that 9 out of 10 TDWTF readers should never be allowed near a compiler... or a computer at all.
What happened to the readership of this site? I used to be able to say that at least most people here could write better code than the WTFs themselves. Now it's like a bunch of beer-gutted tube jockeys snickering and swearing at professional athletes.
Admin
Admin
I can't really do much apart from gape my mouth and shake my head...
At YOU people. My GOD, you people are insane. Apparently, explicitness is a bad thing now?
Admin
Tsk, tsk. Think of the performance hit of all those comparisons! Obviously the best way to implement this function is to use a precomputed lookup table:
Admin
That's what I was thinking, too, as long as x > 0.
I don't know what's wrong with the whippersnappers.
Admin
Admin
Because MSVC still doesn't implement it (they don't even implement C89, although it's a lot closer), so us poor bastards forced to do multi-platform, multi-toolchain development aren't able to use it.
Admin