Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 483 Bytes

File metadata and controls

23 lines (17 loc) · 483 Bytes

C++

The short way

Contibuted by: BraydonKains

This is the way everyone in the Programmer Nullposting group says is the best.

bool isEven(int x) {
    return x % 2 == 0;
}

The bitwise AND way

Contibuted by: Jared0801

This way is slightly more optimized (depending on the compiler) and almost as short, but possibly harder to read.

bool isEven(int x) {
    return (x & 0x1) == 0;
}