Binary, Hexadecimal, Binary Finger Counting Tutorial

While I was thinking of bits and bytes, I was wondering, what would be the most efficient way to determine if a number is even or odd?
Code:
bool isEven(int num)
{
    return ((num & 1) == 0);
}
or
Code:
bool isEven(int num)
{
    return (num % 2 == 0);
}
 
Back
Top