They’re coding for each possible option instead of making the code general and more concise
34
Anonymous1w
private bool IsEven(int number){
return not ((bool) (number & 1))
15
🥰
Anonymous1w
Modular division exists.
Less sarcastically you can divide by 2 for a remainder to check every possible even or odd case
15
Anonymous1w
I don’t even know this language but it seems pretty self explanatory. If a number “IsEven”, it will be true, otherwise it is false
12
Anonymous1w
You have to be baiting
9
Anonymous1w
The fact it’s Yan dev makes this even better, OP you might not know but dude is infamous for being dog water with code
8
Anonymous1w
Jus divide by 2 if the remainder is zero then true if not then false so it would be this symbol % when programming and you can use a condensed version of that
6
Anonymous1w
there’s plenty of atrocious things you could do in C, but whoever did that definitely did it as a joke
4
Anonymous1w
You could literally just use the modular operator to check if a number is even or odd and return an outcome based on that. Like in coding if you basically take a number and tell it to evaluate if the remainder of that number divided by 2 is 0 then that number is even
1
Anonymous#11w
Wdym??
6
AnonymousOP1w
Like there's no way you actually don't get this
3
Anonymous#11w
Well geeeeeeez, thanks for being so kind! You typical CS major that believes they are so above everyone else!! Is it that hard to realize other ppl have no idea about coding AT ALL?!
1
AnonymousOP1w
I'm not a CS major. Look I'll help you work out what's wrong, but the image provides enough context for anyone to reasonably get it, so I won't tell you outright.
First of all, what is this code trying to find?
13
Anonymous#21w
And what does that even mean? So its wrong bc they are using true and false to count numbers instead of a number system?!
3
AnonymousOP1w
Idk what you’re talking about. No it’s not wrong. This can easily be done in one line though, I’ll tell you that much.
9
Anonymous#31w
THANK YOU FOR BEING THE FIRST TO EXPLAIN THIS SIMPLY!!!
13
🌮
AnonymousOP1w
Yeah, they could just divide the number by 2 and check if the remainder is 1 or 0
24
AnonymousOP1w
Odd or even essentially
7
Anonymous#81w
I ain’t even notice who it was cuz I was staring at that disgusting piece of code