How to divide correctly

bitshift op

Other urls found in this thread:

lua.org/manual/5.3/manual.html#3.4.2
en.wikipedia.org/wiki/XOR_swap_algorithm#Reasons_for_avoidance_in_practice
en.wikipedia.org/wiki/XOR_swap_algorithm#Reasons_for_use_in_practice
twitter.com/SFWRedditImages

One of these things are different from the others.

no it isnt. everything divides by 2.

Real programming languages don't support bitshifting, thats just for autistic people lol

Until you consider rounding errors.

lol stfu highlevelfag

because multiply/division is the only purpose of bit shifting : ^ )

who said that?

>
Whats wrong autist? mad that you cant find a job where something like bitshifting is relevant ??
learn java like a normal person lol

there aren't rounding errors where nothing cant be rounded.

Most compilers optimize power of 2 divisions into bit shifts.

Doing actual bit-shifting in your code is autistic.

>Most compilers

If your compiler doesn't do that for you automatically it's shit

>Real language
>Can't even use basic bitwise ops
HAHAHAHA what shit fucking garbage lang do you use? even fucking python has bit ops.

you fucking CIA nigger i wrote my own compiler
the difference between a professional and a ammatuere is if you write your own compiler

god damn shitheads. last one only works on integers.

you nigger stop shittalking if you dont know

IKR fucking autists bro
Who even uses compilers in 2k17 ?? its like you dont want to have a job
LUA

lua isnt a programming language
html is one.

each of these may yield different values on same input

what did he mean by this

>LUA
lua.org/manual/5.3/manual.html#3.4.2

>using an outdated version of Lua

So how's your roblox game coming along?

Actually my job is exactly that.

nice paste aspie

>html
>programming language
Pick one

>Who even uses compilers in 2k17 ?? its like you dont want to have a job
I'm a white man, I wrote my own fucking compiler, I'm not a nigger like Linus. I'm a professional, I started at Ticketmaster 1990 and we wrote a compiler, the difference between an amateur and a professional is you write your own compiler. I have a 20,000 line divine intellect compiler that operates just in time and ahead of time, you seem to be in denial.

My CIA niggers

What language doesn't support bitwise operations?

Wouldn't division of an int by two just get compiled into a bitshift anyway?

Yes. OP is retarded.
Any optimizing compiler will do this.

sorry, i meant literally every compiler.

What's the second one do?

Mulitplies by a half, so the equivalent of dividing by 2.

Or did you mean something else?

Why is the f there?

so it's a float instead of double

It's to tell the compiler that the number is a floating point number.

Ah, right. Thanks.

>Buttshifting floats.

...

where does n come from?

end condition for a loop over n

>x^0.5
>Using XOR
>any year

What is n?

template
void swap(T &a, T &b)
{
a ^= b;
b ^= a;
a ^= b;
}

>inb4 sepples

gamerfood is that you?

How does this work?

en.wikipedia.org/wiki/XOR_swap_algorithm#Reasons_for_avoidance_in_practice

...

en.wikipedia.org/wiki/XOR_swap_algorithm#Reasons_for_use_in_practice

>Because these situations are rare, most optimizing compilers do not generate XOR swap code.

Shitposting aside, it seems like a really bad idea
to use it.

>having bluetooth turned on
>browsing on phone
kys

C has an exponent operator, didn't you know? Here, you can test it:
if (2^5 == 32)
if (3^3 == 27)
if (10^4 == 10000)
if (5^2 != 26)
if (4^3 != 8)
if (2^4 == 4^2) {
printf("exponentiation seems to be working just fine");
}

Wow, I didn't know that! This'll make my code much cleaner.

please don't

Hot

Im taking it you've never done embedded programming
because masking subroutines use bitshift

>bit shifting a signed int

This, people should focus on maintaining and improving modern compilers instead of worrying about autistic bit shifts.

CL-USER> (/ 5 2)
5/2
CL-USER> (* 5 0.5)
2.5
CL-USER> (ash 5 -1)
2

>doing the compilers job
autism

Why don't they include tricks like these in compilers? Would a compiler turn divide by two for an integer into bitshift?

>5/2

>Better solutions descending in C
>Better solutions ascending in CL
Really gets the old noggin joggin'.

Not if you're using Javascript


Speaking of numbers, all numbers are 64-bit, except if you plan to do
any bitwise operation at all, in which case they're silently converted
to 32 bits, than back to 64 again:

Math.pow(2,31) == 2147483648 // true, as expected
1

Only if it's a literal or constant.

What makes you think they don't?

I'd assume it would be a reasonable optimization to expect.