Comment On Some Crazy Reason

One time, out of boredom, 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. At least in theory. I somehow never encountered a file with a "two" bit. But I got one key component right – an understanding of the valid range of values. [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Re: Some Crazy Reason

2009-02-16 09:05 • by First (unregistered)
First!

Re: Some Crazy Reason

2009-02-16 09:07 • by nah (unregistered)
Easy to fix. Just do a search and replace. Changing every 10 in the result to A, no need to change the array.

Re: Some Crazy Reason

2009-02-16 09:07 • by StDoodle (unregistered)
Wow. I find this site entertaining, but often can't follow the coding stuff, as I'm a drafter, not a programmer. When it's immediately obvious to me what's wrong in a code example, you've F'd up big-time!

Re: Some Crazy Reason

2009-02-16 09:08 • by lauwersw
What? You never learnt heptadecimal??!

Re: Some Crazy Reason

2009-02-16 09:10 • by ToHex (unregistered)
Wow, that's Unicode hex! Multi-byte hex characters!

Re: Some Crazy Reason

2009-02-16 09:10 • by Drew (unregistered)
Just need to make sure "10" == "A". You could probably do this with another base class, a few interfaces, some operator overloading, some preprocessor commands, a banana...

Re: Some Crazy Reason

2009-02-16 09:12 • by Cats! (unregistered)
For some crazy reason this comment has 10 words, which doesn't make any sense to me.

Re: Some Crazy Reason

2009-02-16 09:15 • by Kefer
creating a random number using the stringbuilder? WTF?

Setting a visible color (okay, buttumption based on naming) using a random? Sure this wasn't some kind of a college exercise?

Re: Some Crazy Reason

2009-02-16 09:15 • by valerion
Ah, good old Base 16-and-a-bit

Re: Some Crazy Reason

2009-02-16 09:16 • by Westbury (unregistered)
244141 in reply to 244134
I only use heptadecimal when I have a lot of "two" bits come back from my BitVerifier

Re: Some Crazy Reason

2009-02-16 09:17 • by Bosshog (unregistered)
The goggles, they do nothing!

Re: Some Crazy Reason

2009-02-16 09:19 • by Mike (unregistered)
244143 in reply to 244137
Drew:
Just need to make sure "10" == "A". You could probably do this with another base class, a few interfaces, some operator overloading, some preprocessor commands, a banana...


Is this the MacGyver approach to coding? Wouldn't you need a paper clip and a rubber band then too?

Re: Some Crazy Reason

2009-02-16 09:22 • by My name (unregistered)
> One time, out of boredom, I wrote a little utility
> called BitVerifier. It would loop over a folder and
> check every bit of each file.

I'd question it did. The smallest addressable space is the byte.

Re: Some Crazy Reason

2009-02-16 09:25 • by Kefer
244146 in reply to 244145
My name:
>
I'd question it did. The smallest addressable space is the byte.


So? Read a byte and check every bit. What's the problem?

Re: Some Crazy Reason

2009-02-16 09:26 • by seconddevil
making "10" == "A" doesn't solve the problem, because "10" can occur independently (out of "1" + "0") thus creating a "5" char long number. Also, and doing this would also increase the weight of "A" in the random string generation.

Re: Some Crazy Reason

2009-02-16 09:29 • by blub (unregistered)
244148 in reply to 244147
seconddevil:
making "10" == "A" doesn't solve the problem, because "10" can occur independently (out of "1" + "0") thus creating a "5" char long number. Also, and doing this would also increase the weight of "A" in the random string generation.


No way!?!?!?!?!?1111111

Re: Some Crazy Reason

2009-02-16 09:31 • by Mr B
244149 in reply to 244145
My name:
> One time, out of boredom, I wrote a little utility
> called BitVerifier. It would loop over a folder and
> check every bit of each file.

I'd question it did. The smallest addressable space is the byte.


If a byte was made out of cream-cheese, I'd agree with you. Unfortunately, it's usually made out of bits.

Re: Some Crazy Reason

2009-02-16 09:32 • by Someone (unregistered)
The real WTF here is that you wrote a utility that looped though files checking if each *Bit* is a 1 or 0...

Am I missing something or is that kind of redundant?

Re: Some Crazy Reason

2009-02-16 09:33 • by Mr B
244151 in reply to 244150
Someone:
The real WTF here is that you wrote a utility that looped though files checking if each *Bit* is a 1 or 0...

Am I missing something or is that kind of redundant?


Yes, you are missing something.

Re: Some Crazy Reason

2009-02-16 09:36 • by Harry Carey (unregistered)
244152 in reply to 244149
Mr B:
My name:
> One time, out of boredom, I wrote a little utility
> called BitVerifier. It would loop over a folder and
> check every bit of each file.

I'd question it did. The smallest addressable space is the byte.


If a byte was made out of cream-cheese, I'd agree with you. Unfortunately, it's usually made out of bits.


But what if it was made of spare ribs? Would ya eat it?

Re: Some Crazy Reason

2009-02-16 09:36 • by the real wtf fool
244153 in reply to 244151
Mr B:
Someone:
The real WTF here is that you wrote a utility that looped though files checking if each *Bit* is a 1 or 0...

Am I missing something or is that kind of redundant?


Yes, you are missing something.


Did you hear the whooosh, Someone?

Re: Some Crazy Reason

2009-02-16 09:37 • by Nigel Tufnel (unregistered)
I think that there is a Spinal Tap reference lurking in here somewhere. It's better than ordinary hexadecimal it goes to 17. Sort of.

Re: Some Crazy Reason

2009-02-16 09:37 • by PSWorx
244155 in reply to 244142
Bosshog:
The goggles, they do nothing!


Attention! CommentVerifier discovered that your comment does not. Please correct.

Re: Some Crazy Reason

2009-02-16 09:38 • by the real wtf fool
The code is fun, but WTF kind of application would require a random colour generator anyway?

Re: Some Crazy Reason

2009-02-16 09:44 • by FinnGamble (unregistered)
244157 in reply to 244145
My name:
I'd question it did. The smallest addressable space is the byte.


Lol n00b.


int c=fgetc(infile);
int bit=c/128;
if(bit!=0 && bit!=1)
printf("Error! Bit=%d\n",bit);
bit=c/64;
if(bit>2)
bit=bit-2;
if(bit!=0 && bit!=1)
printf("Error! Bit=%d\n",bit);
bit=c/32;
if(bit>4)
bit=bit-4;
if(bit>2)
bit=bit-2;
if(bit!=0 && bit!=1)
printf("Error! Bit=%d\n",bit);
bit=c/16;
if(bit>8)
bit=bit-8;
if(bit>4)
bit=bit-4;
if(bit>2)
bit=bit-2;
if(bit!=0 && bit!=1)
printf("Error! Bit=%d\n",bit);
bit=c/8;
if(bit>16)
bit=bit-16;
if(bit>8)
bit=bit-8;
if(bit>4)
bit=bit-4;
if(bit>2)
bit=bit-2;
if(bit!=0 && bit!=1)
printf("Error! Bit=%d\n",bit);
bit=c/4;
if(bit>32)
bit=bit-32;
if(bit>16)
bit=bit-16;
if(bit>8)
bit=bit-8;
if(bit>4)
bit=bit-4;
if(bit>2)
bit=bit-2;
if(bit!=0 && bit!=1)
printf("Error! Bit=%d\n",bit);
bit=c/2;
if(bit>64)
bit=bit-64;
if(bit>32)
bit=bit-32;
if(bit>16)
bit=bit-16;
if(bit>8)
bit=bit-8;
if(bit>4)
bit=bit-4;
if(bit>2)
bit=bit-2;
if(bit!=0 && bit!=1)
printf("Error! Bit=%d\n",bit);
bit=c;
if(bit>128)
bit=bit-128;
if(bit>64)
bit=bit-64;
if(bit>32)
bit=bit-32;
if(bit>16)
bit=bit-16;
if(bit>8)
bit=bit-8;
if(bit>4)
bit=bit-4;
if(bit>2)
bit=bit-2;
if(bit!=0 && bit!=1)
printf("Error! Bit=%d\n",bit);

That's, afaik, the shortest, easiest and most efficient way to get to the integer values of bits in the C programming language.

Re: Some Crazy Reason

2009-02-16 09:50 • by galgorah
244158 in reply to 244137
Drew:
Just need to make sure "10" == "A". You could probably do this with another base class, a few interfaces, some operator overloading, some preprocessor commands, a banana...
Don't forget the satanic rituals and goat's blood. You will after all need some thrall's to maintain that hellish nightmare.

Re: Some Crazy Reason

2009-02-16 09:53 • by TGV
244159 in reply to 244157
FinnGamble:
My name:
I'd question it did. The smallest addressable space is the byte.


Lol n00b.


int c=fgetc(infile);
...
if(bit!=0 && bit!=1)
printf("Error! Bit=%d\n",bit);

That's, afaik, the shortest, easiest and most efficient way to get to the integer values of bits in the C programming language.

If your irony detector hasn't been calibrated for some time, count until 0x10 before replying to this comment...

Re: Some Crazy Reason

2009-02-16 09:53 • by some crazy chap (unregistered)
244160 in reply to 244153
the real wtf fool:
Mr B:
Someone:
The real WTF here is that you wrote a utility that looped though files checking if each *Bit* is a 1 or 0...

Am I missing something or is that kind of redundant?


Yes, you are missing something.


Did you hear the whooosh, Someone?


[pseudo]
if bit_value == 1 return TRUE
elif bit_value == 0 return TRUE
[/pseudo]


CAPTCHA 'nobis', latin for that guy no one much likes (me)

Re: Some Crazy Reason

2009-02-16 09:53 • by Anonymous (unregistered)
That one I can agree. Definetely a wtf.

Re: Some Crazy Reason

2009-02-16 10:00 • by Lennart (unregistered)
Seems like a junior programmer, which made a small error and blind stared on it for a while and finally giving up. Can happen. His mentor should help him and both move along.

Don't tell me nothing like this ever happened to you people.

Re: Some Crazy Reason

2009-02-16 10:03 • by Khôi (unregistered)
omg! someone found out how scandisk is implemented!

Re: Some Crazy Reason

2009-02-16 10:04 • by Blackice (unregistered)
244164 in reply to 244157
Have you never heard of a loop??

int c=fgetc(infile);

for(int mask = 1; i <= 128; i *= 2)
{
bit = c & mask;

if(bit!=0 && bit!=1)
printf("Error! Bit=%d\n",bit);
}

Re: Some Crazy Reason

2009-02-16 10:06 • by Blackice (unregistered)
244165 in reply to 244164
Err...don't reply before coffee...

if(bit!=0 && bit!=1)

// should be

if(bit!=0 && bit!=mask)

Re: Some Crazy Reason

2009-02-16 10:13 • by My name (unregistered)
244166 in reply to 244146
Kefer:
My name:
>
I'd question it did. The smallest addressable space is the byte.


So? Read a byte and check every bit. What's the problem?


No a problem per se. But it may as well be stored in ternary on the disk for all you'd know.
When you say "check the bits", you don't check physical bits on your physical drive. Nor on any physical memory. Your program semantics include operators that yield ones or zeros. Not the same thing.

But quite some hair-splitting.

Alright, I'll get my coat.

Re: Some Crazy Reason

2009-02-16 10:14 • by Love it (unregistered)
I love it when people can laugh at themselves and even share the joke...
I wrote my share of code like that during my early years... code that just doesn't make sense (although I don't think I every tried to find a bit that wasn't 0 or 1).

Re: Some Crazy Reason

2009-02-16 10:18 • by Code Dependent
I somehow never encountered a file with a "two" bit.
Of course not. The set of possible values for a bit is {0, 1, FILE_NOT_FOUND}.

Re: Some Crazy Reason

2009-02-16 10:18 • by FinnGamble (unregistered)
244169 in reply to 244164
Blackice:
bit = c & mask;


AH, but by using the AND operation you will lose data. You are, essentially, forcing the bits to be one or zero.

Besides, I like the aesthetics of my code better. Each section between the printfs gets progressively longer in an eye-pleasing way.

Re: Some Crazy Reason

2009-02-16 10:21 • by hatterson
244170 in reply to 244166
My name:
Kefer:
My name:
>
I'd question it did. The smallest addressable space is the byte.


So? Read a byte and check every bit. What's the problem?

No a problem per se. But it may as well be stored in ternary on the disk for all you'd know.


Obviously this has never been encountered in the real world as he *clearly* stated he had never run into a '2' bit.

Re: Some Crazy Reason

2009-02-16 10:22 • by Lennart (unregistered)
244171 in reply to 244167
Love it:
I love it when people can laugh at themselves and even share the joke...
I wrote my share of code like that during my early years... code that just doesn't make sense (although I don't think I every tried to find a bit that wasn't 0 or 1).



Indeed. When I look back at the first project I wrote, I kinda have to smile as well.
If this was a person with years of experience I'd say it's ok to get him from the project. In this case, where I assume that it's a new kid's mistake, it's silly to keep him away from a project.

Re: Some Crazy Reason

2009-02-16 10:32 • by Anonymous (unregistered)
Aww, that's the cutest WTF I've seen in a long time. I get annoyed when I see good coders makes stupid mistakes but when you see something like this you realise that the coder didn't even understand a fundamental concept of computer science. It just makes me want to give them a big hug as I tell them that software development is not the right career path for them and kick them out the door.

Re: Some Crazy Reason

2009-02-16 10:33 • by My name (unregistered)
244173 in reply to 244170
hatterson:
My name:
Kefer:
My name:
>
I'd question it did. The smallest addressable space is the byte.


So? Read a byte and check every bit. What's the problem?

No a problem per se. But it may as well be stored in ternary on the disk for all you'd know.


Obviously this has never been encountered in the real world as he *clearly* stated he had never run into a '2' bit.


Well, that's another problem with Jake's report. Obviously in the real world, you'd never run into a '2'. No, you'd simply step on it without noticing. For they are really really tiny wee bits. Even smaller than their cousins bit 1 and bit 0, as the Unified String Theory (at least its UTF-8 variant) teaches us [citation needed].

Re: Some Crazy Reason

2009-02-16 10:34 • by jordanwb (unregistered)
Why would a bit be something other than 0 or 1?

Re: Some Crazy Reason

2009-02-16 10:38 • by Anonymous (unregistered)
Are there really this many people on the site who don't get the bit joke?

Re: Some Crazy Reason

2009-02-16 10:38 • by hatterson
244176 in reply to 244174
jordanwb:
Why would a bit be something other than 0 or 1?


Maybe you're just not sure. As Heisenberg's Uncertainty Principle of Computer Science teaches, the more sure you are of the value of a bit the less sure you are of it's position on the disk

This was just built to verify that someone didn't get overzealous in finding out exactly where a bit was and force it to abandon a value of 1 or 0 since 50% is too high a chance to know the value of a bit if you're absolutely sure of its position.

Re: Some Crazy Reason

2009-02-16 10:40 • by MainCoder (unregistered)
244177 in reply to 244174
jordanwb:
Why would a bit be something other than 0 or 1?


You are not the sharpest knife in the drawer are you?

Re: Some Crazy Reason

2009-02-16 10:42 • by JimmyVile (unregistered)
244178 in reply to 244157
FinnGamble:
My name:
I'd question it did. The smallest addressable space is the byte.


Lol n00b.
That's, afaik, the shortest, easiest and most efficient way to get to the integer values of bits in the C programming language.



for (int c = fgetc(infile); c < 1 || c&(-2) > 1; c>>1);
if (c > 0) printf("Error! bit with value higher than 1 found!\n");


Re: Some Crazy Reason

2009-02-16 10:43 • by JimmyVile (unregistered)
244179 in reply to 244178
Yes I got the joke, I'm just bored waiting for a large compile job.

Re: Some Crazy Reason

2009-02-16 10:45 • by Anonymous (unregistered)
244180 in reply to 244179
JimmyVile:
Yes I got the joke, I'm just bored waiting for a large compile job.
Yeah, sure, whatever you say (I'm sure you have to do loads of compiling in the data entry office)...

Re: Some Crazy Reason

2009-02-16 10:48 • by DivineGod (unregistered)
244181 in reply to 244138
Cats!:
For some crazy reason this comment has 10 words, which doesn't make any sense to me.


This has 10 words too.

Re: Some Crazy Reason

2009-02-16 10:51 • by Code Dependent
244182 in reply to 244181
DivineGod:
This has 10 words too.
No. This.
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Add Comment