- 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
Clearly this programmer does not understand how to use bits like this properly, therefore all they did was create a new problem. So they went from one problem to two...but they're doing it in binary now so they went from one problem to 10.
Admin
Ah crap I screwed up my quotes. Should have been:
Clearly this programmer does not understand how to use bits like this properly, therefore all they did was create a new problem. So they went from one problem to two...but they're doing it in binary now so they went from one problem to 10.
Admin
Admin
Usually they think code is charged by the line, therefore for me to sit and write code that might not get used, or hasn't been budgeted for is a great expense, compared to me sitting in the office reading and posting on TheDailyWTF.
Admin
/comment /thread /article /tdwtf
Admin
And to make his live easier, he wrote a code generator that simply wrote this stuff out... without just using the code generators code in his function.
Admin
Don't you mean 8 problems. Unless you are running this: http://en.wikipedia.org/wiki/Ferranti_Mercury
Admin
You could either use a ternary notation or a bit shift to fix that.
Admin
Wow. Just waste those 256 bytes and generate them into a static array first. It's still terrible tho'.
Admin
Admin
(My first computer had 8 KB. And we liked it.)
Admin
Can some one please post this code with the snipped lines ? Too lazy to do it myself, offcourse.
FYI, I am being paid by lines of code, and am planning to copy paste this code. It will be my December bonus!
Admin
I especially like the ski jumping snowman in the second line.
Admin
This is so awesome! They should add it to PHP!
Admin
I guess that he wasn't "bit-wise"
Admin
Unless that was an intentional comical spelling, I think you'll find the word is poofters.
Admin
whats most interesting is that someone actually had the knowledge to do binary conversion yet they did not had the sence to do it properly.
Admin
Admin
TRWTF is it only handles a byte. Keep on going for 4,294,967,040 >more< cases for my 32 bit machine...and I don't even want to think about this for my 64 bit systems.
Now the programmer who's savvy with bits would just write a program to write that code for an arbitrary number of bits right :-D
Admin
Admin
Admin
I'll say it...
you've got 64 problems and a bit's every one.
Admin
I've never been paid by the line, but a former COBOL shop I worked in (back when the Earth was still cooling) required the programmers (I was 1 of 3) to submit weekly status reports showing how many lines of code we produced per week/day/hour. If we dropped below a certain average, we had to justify where our time went.
Or we just produced more lines.
Admin
Trying to read binary numbers as their decimal equivalent quickly runs into problems as the numbers get big.
Here's how to count in binary:
One, ten, eleven, one hundred, one hundred one, one hundred ten, one hundred eleven, one thousand...
Reading hexadecimal numbers this way runs into the problem that 18 and 1A are homonyms (eighteen vs. "A"-teen). So I suggest reading them by reading the digits (one-eight, one-"A")
Admin
I once had a job where management discussed giving bonuses based on lines of code produced. I got my hopes up: I can easily think of dozens of ways to boost line count. Like, don't write "x=x+2", write "x=x+1" twice. Loops? Crazy idea. Make multiple copies of the code. Etc. Sadly, they dropped the idea.
That said, there are plenty of companies out there that pay by the hour, and that's not a lot different.
When I worked for the government, one project team was given an award, with a big ceremony and a high muck-a-muck presentating a plaque and all that, for producing the most paperwork. I don't mean that they fooled the higher-ups and all they ever really did was produce paperwork. I mean, the stated reason for them receiving the award, for which they were praised by the high officials, was that they had filled out more forms and produced more documents than any other project team. Oh, by the way, the actual software that they were supposed to produce? They never managed to implement most of the required functionality. They were supposed to support 20,000 users, but their system crashed whenever they got more than 7, and they were never able to get it to run with anything remotely resembling a realistic load. The project was eventually cancelled. But, hey, the filled out all the forms correctly.
Admin
I was thinking of the loop being i=0,j=1;j<255;++i,j*=2, but yeah, same idea.
The difference between doing it with a 2- or 3-line loop rather than hundreds of lines of a big case statement is not just that the loop is easier to write, but more importantly that it is easier to verify. I can test the loop version with three or four cases and be confidant that it is correct. But with the "unrolled" version, how do I seriously verify that in all that typing or copy-paste editing, at some point I didn't make a mistake? I've seen exactly that in such code. Buried deep down inside somewhere, instead of saying "rule[0]=0; rule[1]=1;" it actually says "rule[0]=0; rule[0]=1;" and never sets rule[1], because someone made a typo.
Admin
Uh, my Windows 98 box had only 64MB. And that was pretty decent at the time.
I suspect you are talking about hard drive space. He meant primary memory. RAM.
Of course even then, 4GB hard drive space would have been fairly large. Certainly more than the minimum for Win95, which I recall using on systems with only a gig of disk space. With 4GB I think you could even run XP (assuming you didn't plan on installing much else!)
Admin
Admin
And in real life, the obvious follow on to this is that someone who's an even bigger idiot than the person who wrote the original code will say, Oh, there's a place where the value I pass in is the customer flags, but we just got a change request from the user that customer flag #4 should be treated as zero whenever flags 1, 2, and 3 are 1, 0, and 1 and the customer has account type W, so I'll just add this global that is true when the customer account type is W, and let's see, I think I'll call it "customer_account_type_w" ... no, that's too much to type, let's just call it "cw" ... and then inside case 13 I'll just add "if (cw) rule[4]=0 else rule[4]=1", and, yeah, that should take care of it.
I have seen this scenario hundreds of times.
Admin
Generalized:
You have n problems. You think "I know, I'll use bits." Now you have 2^n problems.
Admin
Who said reinventing the wheel was a bad idea? If we would not have reinvented the wheel time and time again in the past, we would still have stone tires on our 'cars', would not be able to go faster than 10 mph, and would break said wheels after somewhere around 20 miles.
Admin
TRWTF is how bad all the solutions are in the comments also are. It's not hard, people. You don't need to overuse STL and definitely shouldn't hardcode the size of the output array.
The closest was this one: rules[i] = inputInt & (1 << (size-i)); However, that will not set the lowest bit in each array element but bit being checked.
Replace type with the desired data type.
void toBitArray(type var, unsigned char* bitArray) { for( int i = 0; i < sizeof(type)*8; ++i) { bitArray[i] = (var >> i) & 1; } }
Admin
Dammit, I always forget Poland. What with it being all the way over in Europe, and all.
Admin
And now you have discovered the difference between reinventing and merely iterating.
(Captcha: erat - I smell erat!)
Admin
Unless the person had a reason for doing so, it's not even semantically correct. The bits are in reverse order.
Captcha: erat = Electronic Rat
Admin
Admin
www.folklore.org/StoryView.py?story=Negative_2000_Lines_Of_Code.txt
Admin
http://www.folklore.org/StoryView.py?story=Negative_2000_Lines_Of_Code.txt
Admin
Admin
Ya got masking problems? I feel bad for you son. I got 1100011 problems But a bit ain't one. ;)
Admin
I did have a job once where productivity - though not directly pay - was measured by lines of code.
Same job where I was asked to make the internet 100% reliable, when dial-up was the standard (yes, this was years ago). It was like living a Dilbert comic.
Admin
The operator ^ doesn't really do exponents in javascript does it? It's a bitwise XOR in every language I know.
Admin
And Microsoft is the result.
Admin
I call bullshit on this one. No one is that stupid. If they were, they wouldn't be able to use a keyboard.
Admin
I'm working at a company where my boss is now a principal engineer and running a team. He has a degree in software engineering, but doesn't understand number bases. But loves UML design. In a company doing embedded systems. Go figure.
Admin
Don't you mean "I know, I'll use bitmasks." Now you have 11 problems.
Admin
Is that you Bruce?
Admin
Admin
Admin
I see what you did there.
There are 10 kinds of people in the world, those they get binary, and those that don't.