[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 mod 2 instead of bitwise and 1 to test for odd/even

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: 21
Thread images: 1

File: Girls.png (490KB, 449x401px) Image search: [Google]
Girls.png
490KB, 449x401px
>he uses mod 2 instead of bitwise and 1 to test for odd/even numbers
>>
>>59822436
what's the difference though?
>>
>>59822754
OP gets to be a special snowflake by using the second method.
>>
>>59822754
None. The compiler does the same either way. Mod 2 is more readable / easier to understand.
>>
>>59822781
Kill yourself, you dumb fucking shit stain.
>>
>>59822787
Niceme.me
>>
>>59822784
Yes, it is easier to read and understand (for script kiddies that don't know what a bit is)


>>59822754
Bit test is what the compiler turns modulus 2 in to. All it does is prove you don't know what bitwise and does.
>>
>>59822885
>All it does is prove you don't know what bitwise and does.

Yeah that'll surely keep me up at night.
>>
>>59822436
My processor reads java bytecode and has no idea what a bitwise is.
>>
>>59822894
> Interviewee 1 does % 2
> Interviewee 2 does & 1

Outcomes
> Interviewer is a dumbshit and thinks & 1 will confuse people.
> Interviewer actually knows that to check if base 2 number odd you see if the first bit is 1.
>>
>>59822972
Interviewer knows interviewee is correct, but solving it that way is a measure of immense autism. Interviewer decides he is not a good "cultural fit"
>>
>>59822972
>Outcomes
>Interviewer doesn't give a shit because they both work and bitwise operations weren't a requirement of the test.
>>
>>59822972
>Interviewer picks the interviewee who doesn't have autism because working with a team is essential
>you don't get the job
>>
Obviously the correct way is
bool iseven (int x)
{
if (x & 0 == 0)
return false;
else
return true;
}
>>
>>59823133
>working with a team is essential
If your team doesn't know about bitwise operations, then it sucks. mod 2 has no advantage over &1.
>>
>>59825838
Yes it does dumb ass, it's readable and intuitive, you're acting like bitwise operators are some sacred thing only you know of lmao, literally like csc 102.
>>
>>59825761
>not doing return !(x & 0 == 0);
>>
>>59825761
bool iseven (int x)
{
int i = x/2;
if (x - i*2 != 0)
return false;
else
return true;
}


ftfy
>>
>>59822436
Doing that ties your code to a specific endianess aka a less portable solution.
>>
>>59822784
>>59822885
Last I checked the JVM wouldn't do that
>>
Won't your compiler just optimise that anyway?
Thread posts: 21
Thread images: 1


[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.