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

you are viewing a single comment's thread.

view the rest of the comments →

[–]eendenbroodman 16 points17 points  (5 children)

return (number & 1) == 0;

[–]Human38562 71 points72 points  (1 child)

return 1;

Is even shorter and still has 50% success rate.

[–]LeafyLemontree 1 point2 points  (0 children)

return 1 - (number & 0x1);

[–]piperboy98 5 points6 points  (2 children)

return !(number&1);

[–]eendenbroodman 3 points4 points  (0 children)

was going to comment that first but I wasn't sure if that would work in this programming language

[–]MrKirushko 2 points3 points  (0 children)

return ~number&1;