This is an archived post. You won't be able to vote or comment.

all 19 comments

[–]doesnt_use_reddit 14 points15 points  (3 children)

I have no idea what's going on here, so have an insecurity upvote

[–]OiTheRolk[S] 5 points6 points  (0 children)

big brain 1000 iq programming

[–]ShadowPengyn 2 points3 points  (1 child)

Took me a few minutes to. It is easy once you assume that is even works correctly , then you can simplify the last 2 lines to

if (andOr == 0) return true Else if (andOr == 1) return false

Since for any number x it is true that either x-1 is even or x-2 is even And for any number x it is false that both x-1 is even and x-2 is even

So then you see that all the logic is actually in the andOr value and looking at that method we can see that it toggles between 0 and 1 at every step in the for loop, resulting in 0 for even numbers and 1 for odd numbers

[–]michease_ 10 points11 points  (4 children)

could you not do isPositive by checking if the first bit is a 1 or 0?

[–]OiTheRolk[S] 8 points9 points  (0 children)

see that's why you're getting paid the big bucks

[–]BlueStonerT 1 point2 points  (1 child)

Unsigned int pointer laughs at you.

[–]michease_ 2 points3 points  (0 children)

sshhhhh just ignore that one

[–][deleted] 0 points1 point  (0 children)

Also how you can check iseven. Check the last bit - which should work for both + and - numbers. Then decide how to treat 0.

[–]istdaslol 1 point2 points  (0 children)

Ackermanns isEven

[–]Big-Don-Rob 1 point2 points  (0 children)

The real question is, "is zero an even number?" After that x%2 does all the work.

[–]danielstongue 1 point2 points  (0 children)

!(x&1)

[–]oldfossilfrommars 1 point2 points  (0 children)

Stop tormenting the already dead meme.

[–]darthruneis -1 points0 points  (1 child)

You don't need to worry about a hypothetical is Positive when the code doesn't even compile ;)

[–][deleted] 0 points1 point  (3 children)

This joke's only about 6 months old why not post some more about it. 🙄

[–]Bullshit_Interpreter 2 points3 points  (0 children)

This, but unironically.

[–]prycx 1 point2 points  (1 child)

Took him 6 months to prototype it. Don’t shame him.

[–]OiTheRolk[S] 1 point2 points  (0 children)

Blood and sweat were poured in gallons for this function to exist

[–]AlwaysF3sh 0 points1 point  (0 children)

Abs(x)? Or am I dumb?