>he uses binary operators on numbers in the set of integers.
>>56293323
This. Whenever I see a xor swap I know the code is shit.
Elaborate please
What?
You mean doing a+b where a and b are integers is bad?
>>56294205
What did he mean by this?
>>56293323
That's a big katana.
>>56294634
really?
>>56294634
nah its just a manlet
>>56294634
For you.
Good damn that's cool.
Screw the haters.
>>56294205
No it's switching the values if variables a and b by using XOR rather than and intermediate variable c
Be honest, if you saw that guy and he demanded your wallet you'd give it to him
>>56294634
isn't that a nodachi?
>>56294836
washing pole
>>56294776
And what's so bad about that?
>>56294782
He's probably too weak to wield it properly.
>>56293323
looks like a charityshop highlander
Aren't bitwise operations nearly always faster than division, even on integers?
>>56294782
Beta detected.
I could easily outrun this scrawny kid.
>>56295493
If you don't use optimization it is.
>>56293502
>Tfw xor swap is slower and people still use it
>>56295493
Optimizers take care of that. Using them in unintuitive situations just makes your code unreadable.
Also, the xor-swapping thing is actually slower then whatever modern optimizers produce with an intermediate variable. Look at the assembly produced by:void swap_xor(int *x, int *y)
{
*x ^= *y;
*y ^= *x;
*x ^= *y;
}
andvoid swap(int *x, int *y)
{
int z = *x;
*x = *y;
*y = z;
}
You'll see that the first one usually produces much more instructions than the second one. The reason is that in order to xor the variables, they need to be moved into registers anyway, so instead of applying the xor operation you might just as well put them back into different places. Looking at it like that, the xor method is actually kind of ridiculous.
>>56295860
Yeah, I remember reading that the xor swap isn't really useful anymore besides in situations where memory is at a premium.
>>56293323
Don't know if you know this, but there was a saying in Japan.
'The bigger the user's blade, the smaller his penis.'
Your conclusion.
>>56295860
> he uses next line style in C
>he doesnt suck multiple cocks at all times
>>56295226
It's stupid. It's doing things terribly for the sake of being different. It's an easy way to introduce bugs when you would never need to. It's like using gotos instead of loops. It's stupid and people who go it are retards.
+, -, /, *, %, &, |, and ^, <<, >>, &&, and || are all binary operators that apply to integers. Are you telling me I cannot do any arithmetic on integers whatsoever?
>>56294776
OP mentioned nothing about XOR swap, although it is incredibly inefficient, especially on RISC architectures that would have to make numerous loads/stores with XOR swap.
>>56298181
Please stop
http://www.tutorialspoint.com/cprogramming/c_bitwise_operators.htm
>>56295860
What about this?
*x -= *y;
*y += *x;
*x = *y - *x;
>>56298292
OP is deriding the use of any binary operators, not merely bitwise operators. If it takes two operands, it is a binary operator. Incidentally, ~ is not a binary operator; it is a unary operator. Despite this, your link refers to the bitwise negation operator as a "Binary Ones Complement Operator"
>>56298181
Yes, arithmetic operations use inefficient XOR and have to be executed sequentially, which has massive overhead.
>>56298510
While you're technically correct, everyone (except you), understood the post.