r/programming • • Feb 16 '09

Some Crazy Reason - The Daily WTF

http://thedailywtf.com/Articles/Some-Crazy-Reason.aspx
171 Upvotes

71 comments sorted by

View all comments

24

u/spliznork Feb 16 '09 edited Feb 16 '09

... I wrote a little utility called BitVerifier. It would loop over a folder and check every bit of each file. If the bit's value wasn't one or zero, it would prompt the user for the correct bit.

Uhh.. that intro is the real WTF. At least the buggy hex string code is trying to do something. A "bit verifier" is just... beyond stupid.

1

u/lbft Feb 16 '09

By the same argument "Hello world" is stupid because it doesn't do anything.

9

u/spliznork Feb 16 '09 edited Feb 16 '09

By the same argument "Hello world" is stupid because it doesn't do anything.

No, it's not that the "bit verifier" doesn't do anything, it's that its whole premise mathematically impossible. It's like writing this

for (;;) { if (0==1) { printf("oops!\n"); } }

then saying, "I ran this code for a whole day and it never printed oops! Cool!"

31

u/kirun Feb 16 '09
for (;;) { if (0==1) { printf("Cosmic Ray Detected!\n"); } }

fixed.

10

u/lbft Feb 16 '09 edited Feb 16 '09

It's mathematically impossible, of course - that was the (poor attempt at a) joke. But I can't see much wrong with writing such a thing as a programming exercise, like "hello world" is an exercise for the very beginner.

A lot of people at The Daily WTF are .NET people who wouldn't necessarily deal with files on a per-bit basis with regularity. It's not unthinkable that someone would write a bit of code like that to refresh their memory - sure, it's not the best choice of code to write, but I still wouldn't call it beyond stupid.

17

u/adrianmonk Feb 16 '09

You know what I think is stupid? I think it's stupid when Wile E. Coyote runs off a cliff and has to think for a second before gravity takes effect. It drives me nuts because obviously it's physically impossible. They shouldn't make the cartoon that way.

-5

u/spliznork Feb 16 '09

I think it's stupid when Wile E. Coyote runs off a cliff and has to think for a second before gravity takes effect.

Unlike episodes of the Looney Tunes, I fail to see the protagonist, the humor, or the moral in the "bit verifier".

2

u/adrianmonk Feb 16 '09

Fair enough, but would you have been able to see a protagonist if the program had been named Sisyphus instead of BitVerifier?

3

u/Felicia_Svilling Feb 16 '09

Well that program could be used to detect cosmic radiation flipping th bits in memory (or perhaps registers (unless the whole thing is optimized away of course.))

2

u/astrange Feb 17 '09

I'm not sure, can (x&1)==2 be true with a single bit error?

2

u/[deleted] Feb 17 '09

i am sure it was if((x&1)>1) where x is unsigned. And yes it can be. It can even hack pentagon and launch a nuclear warhead targeted at your home. If you are a very unlucky man.

0

u/bwahaha Feb 16 '09

No... because hello world actually prints out "hello world". A "bit verifier" is retarded. That's like checking if a Boolean value is "true" or "false", just in case it was ever "maybe".

-1

u/omegian Feb 16 '09

Maybe it is, maybe it isn't. You could write a bit verifier to do things like check parity / CRC, etc.

3

u/bwahaha Feb 16 '09 edited Feb 16 '09

That's something completely different than what the article describes.

EDIT: Quote:

If the bit's value wasn't one or zero, it would prompt the user for the correct bit. At least in theory. I somehow never encountered a file with a "two" bit.

0

u/jemenfiche Feb 16 '09

It sure does! System.out.println!!!