What was the worst piece of code you've ever laid your eyes upon?

Gavin Lopez
Gavin Lopez

What was the worst piece of code you've ever laid your eyes upon?

All urls found in this thread:

daniweb.com/programming/software-development/threads/440954/can-t-fix-error-in-my-program
en.wikipedia.org/wiki/Modulo_operation
desuarchive.org/sci/thread/8366390/

Lucas King
Lucas King

daniweb.com/programming/software-development/threads/440954/can-t-fix-error-in-my-program

Julian Cook
Julian Cook

What the actual fuck. That gave me cancer

Joshua Lewis
Joshua Lewis

Oh fuck is this where that meme came from?

Nathaniel Allen
Nathaniel Allen

Don't know shit about programming. Is there something that basically would take all even numbers, This seems pretty inefficient, just trying to learn.

Andrew Anderson
Andrew Anderson

Learn the definition of an even number.

James Brooks
James Brooks

I know what an even number is mate. Could yoou do something like this:
if number can be divided by 2 then output number is even
pls no bully

Dominic Baker
Dominic Baker

Modulus. man.
If it equals one, odd. If it equals zero, even.

Grayson Wilson
Grayson Wilson

More precisely
If number has remember 0 when divided by 2 then output number is even

Anthony Reed
Anthony Reed

remember

Brody Torres
Brody Torres

My own.

Leo Rodriguez
Leo Rodriguez

Fuck I totally forgot about that. Thanks senpai
Remember?

Jace Richardson
Jace Richardson

Enters 102
Your number is odd

Austin Hall
Austin Hall

Same tbqh

Carson Richardson
Carson Richardson

Code reviews make me feel stupid

Jordan Howard
Jordan Howard

float x;
if (x/2 == int(x/2)) return "even";
else return "odd";

James Cooper
James Cooper

Slow and inefficient. Do bitwise AND with 1 to check if number is odd.

William Wood
William Wood

It's fucking great .

Parker Young
Parker Young

if(/2|4|6|8/.test(number.toString().split('')[number.length])) console.log('even')

Cameron Howard
Cameron Howard

Something most anons can agree with at this point is to remove the inline archive.

Owen Murphy
Owen Murphy

Wish I had the patience to get into this on my own. What language is this btw.

Easton Cox
Easton Cox

it's C i think

Jason Clark
Jason Clark

Remainder

Matthew Martin
Matthew Martin

Is there something that basically would take all even numbers

en.wikipedia.org/wiki/Modulo_operation

Finds remainder after division. Only odd numbers leave remainders. So if you check the modulo of a number and it returns a remainder, it's an odd number and if no remainder it's an even number.

In php, $even = $var % 2 ? false : true;

Connor Thomas
Connor Thomas

:^)

If Number rem 2 = 0 then 
Put_Line("Even");
end If;

Blake Kelly
Blake Kelly

int x
scanf("%d", &x)
printf("%s", (x % 2 == 0)? "even", "odd");

Ian Adams
Ian Adams

STAND ASIDE

fresh from /sci/

Mason King
Mason King

Jesus fuck

Camden Green
Camden Green

Daily reminder that doing this will do nothing for performance since thw compiler isn't retarded, but will make the code less understandable, especially to beginners, and if you do this, you are just showing off your epeen with no merit.

David Gomez
David Gomez

You have to think of it terms of 'is there a test that I can do which will always tell me if a number is even?'

Such as: 'All even numbers can divide into two equal parts' - so if you divide the number by two and get one left over then it's odd.

James Sanders
James Sanders

We should start a new Cred Forums thread where we post these images along with correct solutions (or better yet, even worse solutions).

Aiden Cox
Aiden Cox

holy fuck
link to thread?

Michael Scott
Michael Scott


if(x % 2 === 0) {
document.write("Even Steven! XD";
}
else {
document.write("That's odd, Todd! haha");
}

Jonathan Reed
Jonathan Reed

Slow and inefficient. Do bitwise AND with 1 to check if number is odd.

... I think the fastest way then would be to read the least significant bit. But I think that only works with integers.

Evan Gutierrez
Evan Gutierrez

it might not be that fresh tobeqfh
desuarchive.org/sci/thread/8366390/

never seen it before though

Juan Collins
Juan Collins

I think you missed the joke there, buddy.

Carter Jenkins
Carter Jenkins

If you need to keep the function call format, even though it's disgusting, you just logical or the inputs and return.

Owen Diaz
Owen Diaz

if (!(num & 1)) {
// Number is even
}

Sebastian Cook
Sebastian Cook

x = y % 2 ? 0 : 1;

Jose Rodriguez
Jose Rodriguez

The scary thing is that your life might depend on code written by these people.

Alexander Kelly
Alexander Kelly

I think the fastest way then would be to read the least significant bit.
You can't just read one bit from memory though, you have to read one or more bytes and extract that bit with bitwise operators.

But I think that only works with integers.
True

Jaxon Rogers
Jaxon Rogers

A company that I was at a few years ago gleefully told me that they were 'approaching 1 million lines of code'.

When I got to the code I found 50 files containing about 20,000 lines each.

The company had never performed any kind of QA or Code review in 8 years.

A bug in the threading was caused by a poem written by one of the developers kids in the comments commenting over some variables.

Carter Kelly
Carter Kelly

This is a great way to make code less readable while adding no value whatsoever.

Benjamin Barnes
Benjamin Barnes

tfw your pacemaker's control software was written in Visual Basic

Noah Powell
Noah Powell

Look at that horrible code on the left. It was probably written by a fucking white male!

Lucas Scott
Lucas Scott

what a shitty code!

function atLeastOneTrue(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z){
if(Array.prototype.slice.call(arguments).reduce((fu, fug) => fu+fug)) return true
if (!Array.prototype.slice.call(arguments).reduce((fu, fug) => fu+fug)) return false
}

Zachary Hill
Zachary Hill

A bug in the threading was caused by a poem written by one of the developers kids in the comments commenting over some variables.

Grayson Ward
Grayson Ward

^_^

Ryder Bailey
Ryder Bailey

return 5 because I'm so random yay :D
This is shooped, right?

Robert Howard
Robert Howard

That image is a troll.

Jeremiah Lopez
Jeremiah Lopez

I don’t think this is real honestly

I think I was thirteen when I first had to do this, and I was smart enough to compare rounded and unrounded quotients

Jaxson Johnson
Jaxson Johnson

Depends on your priorities. I work on real-time systems so we do stuff like this all the time.

Jaxon Perez
Jaxon Perez

Nothing wrong with Visual Basic per se, it's good for simple UIs as long as you know what you're doing.
Of course, you don't want to make pacemaker *firmware* with it.

Adrian Rogers
Adrian Rogers

Even the shittiest compiler will optimize that comparison. It's just a bad habit that serves no purpose.

Brayden Campbell
Brayden Campbell

Who still uses pascal?

Ryder Fisher
Ryder Fisher

Trust me, compilers these days are smart enough to omit division instructions when it encounters a % 2.
If your compiler doesn't to that it's probably from the 70s or something and you might consider upgrading.

Evan Garcia
Evan Garcia

It's not Pascal.

That is also part of the problem.

Jayden Allen
Jayden Allen

The left code is what happens when you let only white male work on your program,... not asian, pajeet, woman who code or fat feminist... that's what you get...

Jace Wilson
Jace Wilson

A piece of code written in Pascal from 1995. And they needed was some simple math, but instead they opted for stupidity.

pic related.

Blake Cruz
Blake Cruz

even and odd only contains integers so what's the problem?

Gavin Green
Gavin Green

imblying that uncommented, undocumented code is superior just because it's shorter
ishygddt

Thomas Hill
Thomas Hill

I bet you fell for the 'xor variables to swap them' meme

Angel Gomez
Angel Gomez

the windows nt source, not joking.

Jack Ward
Jack Ward

It is commented... the original one said: "What the fuck" in the i = 0x5f3759df - (i >> 1); line

Camden Campbell
Camden Campbell

I've seen the source for Adobe Photoshop. I still have nightmares about it

Carson Anderson
Carson Anderson

Give us an example, annon!

Leo Mitchell
Leo Mitchell

tfw had to learn C from old ass faggots who insisted that we only use a specific extremely weird compiler, in linux that we had to download and use no other compiler.
start writing overloading functions
they compile in the compiler im using
try the course compiler
it doesnt work
try a different one
it works
lecturer tells me it needs to compile in their compiler
compiler buggy as fuck
realise it was caused by a blank space character after an end like character causing the compiler to shit itself
CS never again
i was studying engineering

Carson Bell
Carson Bell

Or:
$even = $var % 2 == 0

Grayson Cooper
Grayson Cooper

not doing if userNumber in [2,4,6,8,10...100]

Oliver Miller
Oliver Miller

abs(usernumbe)r -= 2 while abs(usernumber) > 0
return usernumber == 0

Alexander King
Alexander King

m8 it's easier than that. You can solve it with basic math.

Noah Powell
Noah Powell

not doing if(userNumber % 2 == 0)

Luis Powell
Luis Powell

how about

function atLeastOneTrue() {
return [].reduce.call(arguments, (prev, curr) => prev || curr, false);
}

Logan Cooper
Logan Cooper

this

Disable AdBlock to view this page

Disable AdBlock to view this page

Confirm your age

This website may contain content of an adult nature. If you are under the age of 18, if such content offends you or if it is illegal to view such content in your community, please EXIT.

Enter Exit

About Privacy

We use cookies to personalize content and ads, to provide social media features and to analyze our traffic. We also share information about your use of our site with our advertising and analytics partners.

Accept Exit