0
10

[–] taxation_is_slavery 0 points 10 points (+10|-0) ago 


float Q_rsqrt( float number )
{
    long i;
    float x2, y;
    const float threehalfs = 1.5F;
 
    x2 = number * 0.5F;
    y  = number;
    i  = * ( long * ) &y;                       // evil floating point bit level hacking
    i  = 0x5f3759df - ( i >> 1 );               // what the fuck?   <-- THIS HERE
    y  = * ( float * ) &i;
    y  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration
//  y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed
 
    return y;
}

Probably a few others in business apps, but they elicit the wtf, and don't ask it.

0
4

[–] for_satan [S] 0 points 4 points (+4|-0) ago 

That one is always a good one. Made a lot of game code faster.

0
4

[–] CathyTheGreatsHorse 0 points 4 points (+4|-0) ago 

That one is always a good one.

Is it well known? Just curious if there is a story behind it.

Seems like that witchcraft would be near impossible to troubleshoot without a deep understanding of how the floating point data type worked.

0
7

[–] yewbontheboat 0 points 7 points (+7|-0) ago  (edited ago)

Came across a set of comments in an automated mrp export program written in c that is about 10 years old

//if (qty == 507)

//return;

//why the fuck did I have to comment this out

//why did you even setup this fuck you bomb to go off 3 years after you left

Or something like that haha, I of course left it in

0
6

[–] kilroy 0 points 6 points (+6|-0) ago 

if ($response->error) { // sometimes our response times out
// do something
} else { // but the dude abides
// do something else
}

0
16

[–] dogmatic 0 points 16 points (+16|-0) ago 

Back in the day, in an age before the internet here was a COBOL payroll system. The system ran weekly. There was an error message generated for the check stub description line if an amount had more than 4 digits for dollars (>9999.00). The error message was "THIS PERSON MAKES TOO MUCH MONEY". It was triggered. Management was...somewhat less than pleased.

0
9

[–] captbrogers 0 points 9 points (+9|-0) ago 

I can't remember it exactly, but it was something like:

Don't edit this function. It looks screwy, you know It, I know It.
But it works. Seriously, don't change it. $TeamLead, I'm talking to you.

Backstory: My team lead was heavily against using any 3rd party code, including frameworks (writing PHP like it was 1998, but it was just two years ago!).

So I had to writing something that does pretty much what Carbon does, but object oriented code wasn't used on this project. Had to do it as procedural with several functions. Any attempt to just scrap the file and rewrite it would end up just as corrupted with spaghetti as before as he made some edits. I'd get it working, he'd break it again. I lasted 6 months at that job.

0
1

[–] for_satan [S] 0 points 1 point (+1|-0) ago 

We had something similar in a code base that I worked in, effectively

This is 10, because this is what the app needs

It was also PHP coded like 99, in 2012

0
1

[–] captbrogers 0 points 1 point (+1|-0) ago 

Same kind of mentality I had to face. It was salt in the wound because I took the job out of necessity. I had to drive over 40 miles one way, so it took me nearly an hour because of traffic when driving.

0
4

[–] taxation_is_slavery 0 points 4 points (+4|-0) ago 

If a company survives long enough on products like that, they usually start asking why development is so expensive, then they outsource to Indians which sends the company into a swan dive above concrete.

0
2

[–] captbrogers 0 points 2 points (+2|-0) ago 

Oh they already did that for the HTML/CSS. Tables. Tables everywhere. Nested. I was surprised it didn't say "best viewed in IE".

[–] [deleted] 0 points 4 points (+4|-0) ago  (edited ago)

[Deleted]

0
0

[–] for_satan [S] ago 

Oh, nice! I hadn't ever seen that before.

0
2

[–] emag 0 points 2 points (+2|-0) ago 

While not exactly "the wild", I came across an example of a comment that wasn't helpful in a textbook back in college. The comment was "horse string length into correctitude". I've made it a mission to use this comment whenever I need to manipulate a string to adjust its length to something the code can handle, just to ensure that it's a legit and helpful comment.

0
1

[–] for_satan [S] 0 points 1 point (+1|-0) ago 

God that sounds awful for a textbook. No wonder a fair bit of people fail out of CS.

0
0

[–] Enemby ago 

It could be intentionally bad, it's odd wording by /u/emag .

0
10

[–] Unleeb 0 points 10 points (+10|-0) ago  (edited ago)

I have two that come to mind:

First one was a piece of software used to simulate some military hardware interface. Since I do not have access to the code anymore, this is a recreation from memory:

// The following code is sub-par. We know. There have been several
// attempts to improve the code, but all attempts have failed. To warn
// future brave souls, increase the counter when you admit defeat.
//
// Defeated souls count: 17
...

And another one, which I merely have observed on the Internet (Edit: As pointed out by Enemby; this one is from xkcd):

int random() {
    return 4; // chosen by fair dice roll; guaranteed to be random
}

0
2

[–] Enemby 0 points 2 points (+2|-0) ago 

the 2nd one is from xkcd.

0
0

[–] Unleeb ago 

How could I not remember that?!

load more comments ▼ (7 remaining)