Check out this cool new code i just invented

check out this cool new code i just invented

float Q_rsqrt( float number )
{
union {
float f;
long i;
} conv;

float x2;
const float threehalfs = 1.5F;

x2 = number * 0.5F;
conv.f = number;
conv.i = 0x5f3759df - ( conv.i >> 1 ); // what the fuck?
conv.f = conv.f * ( threehalfs - ( x2 * conv.f * conv.f ) );
return conv.f;
}

Other urls found in this thread:

en.wikipedia.org/wiki/Fast_inverse_square_root
twitter.com/AnonBabble

what is that for?

Lurk more

fast inverse square root

Check out this new code I invented
Int main(void) {
Printf("op is a faggot");
Return 4chins; }

I dunno if it's a thing but can we get a fake/comedy code thread?

>float Q_rsqrt( float number )
>( float number )
>not (float number)

it doesn't compile.. is that c or java?

Isn't this technically undefined behavior?

Yes, but since it was written specifically for x86 and will properly work there no one should give a fuck.

It's c but it's wouldn't actually compile because I didn't define "4chins"

>I don't understand C readability standards

const float threehalfs = 1.5F;
I've never understood the point of this. Is there some kind of compiler optimization that makes this better than simply magic-numbering 1.5f in its place?

>check out this cool new code i just invented

en.wikipedia.org/wiki/Fast_inverse_square_root

kys op

...

>I don't know either, let me just make fun of him

>I'm a webdev and don't know what constants are

>If I mock him enough maybe nobody will notice I'm also retarded

>i will distance myself from my earlier post, that way, i can avoid the shame of not knowing what a constant is

Look ma he keeps doing it

>I've never understood the point of this. Is there some kind of compiler optimization that makes this better than simply magic-numbering 1.5f in its place?

You're not fooling anybody, brainlet friend

>webdev who doesn't know what a constant is
>calling others brainlets

>k-keep insulting him, that'll make me sound like I'm not also an idiot!

>if I'm a retarded webdev, everyone else must be too

>s-stop resisting my insults!

t. webdev subhuman

Keep trying, you might feel less called out at some point

Not everyone is a webdev, brah

The nostalgia of the old days when people actually bothered to optimize shit.

C'mon, keep going.

C'mon, keep going.

cool, too bad that any gpu made after 95 renders that obsolete

>Is there some kind of compiler optimization that makes this better than simply magic-numbering 1.5f in its place?

stay away! this is hacker code stealing nude photos!

Still not fooling anybody.

C'mon, keep going.

Boy I really got under your skin didn't I

I hope you learned something today, webdev. This is why we laugh at you, you legitimately don't understand what a constant is. You give real programmers a bad name is all I'm saying.

So sad to see you this upset.

its not necessary

Okay I feel bad for bullying you, do you want me to tell you, webdev?

>Now that I've spent 20 minutes googling to make sure that hard-coded magic numbers aren't actually faster than constants, I can act like I knew all along!

That's what I thought, it always just seemed so odd that they would bother to declare it as a const since it's only called once.
I guess originally they ran the operation twice but the production code had one iteration commented out, so it just got left in.

My language doesnt need constants. I don't even use variables.

Not everyone is a brainlet like you, webdev. Try using your head a little before asking questions that an IT intern could answer.

>I've never understood the point of this. Is there some kind of compiler optimization that makes this better than simply magic-numbering 1.5f in its place?

Imagine having your ego this fucked up by somebody calling you out.

Imagine not knowing what a constant is.

Imagine having no reading comprehension.

Imagine being unable to detect ironic situations.

>I-i was just pretending!

>I-i wasn't s-serious

No, see, I was. I wanted to know if there was some kind of optimization taking place that warranted declaring a constant for a value that was only being used a single time in local scope.

You, however, are just an idiot.

So in other words, you don't understand what a constant is. Stick to web development, my dude.

Maybe you should take an english course or something, you seem to have a real problem understanding basic sentences.

t. webdev too retarded to understand what constants are

>itt: autism

t. illiterate

t. webdev