[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

>he uses binary operators on numbers in the set of integers.

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 33
Thread images: 3

File: 494812763512.jpg (165KB, 1032x774px) Image search: [Google]
494812763512.jpg
165KB, 1032x774px
>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.
>>
File: 201607221946411006167005.png (5KB, 238x212px) Image search: [Google]
201607221946411006167005.png
5KB, 238x212px
>>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;
}


and

void 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.
>>
File: intelligent life - gender.png (179KB, 480x421px) Image search: [Google]
intelligent life - gender.png
179KB, 480x421px
>>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.
Thread posts: 33
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.