They’re coding for each possible option instead of making the code general and more concise
34
Anonymous4w
private bool IsEven(int number){
return not ((bool) (number & 1))
15
🥰
Anonymous4w
Modular division exists.
Less sarcastically you can divide by 2 for a remainder to check every possible even or odd case
15
Anonymous4w
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
Anonymous4w
You have to be baiting
9
Anonymous4w
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
Anonymous4w
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
Anonymous4w
there’s plenty of atrocious things you could do in C, but whoever did that definitely did it as a joke
4
Anonymous4w
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#14w
Wdym??
6
AnonymousOP4w
Like there's no way you actually don't get this
3
Anonymous#14w
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
AnonymousOP4w
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#24w
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
AnonymousOP4w
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#34w
THANK YOU FOR BEING THE FIRST TO EXPLAIN THIS SIMPLY!!!
13
🌮
AnonymousOP4w
Yeah, they could just divide the number by 2 and check if the remainder is 1 or 0
24
AnonymousOP4w
Odd or even essentially
7
Anonymous#84w
I ain’t even notice who it was cuz I was staring at that disgusting piece of code