IsOdd is a check code snippet to determine if an int is odd.
bool IsOdd(const int i) noexcept
{
return i % 2 != 0;
}
Below is an example of an IsOdd
implementation, that has a broken oddness check:
//Don't: broken oddness check
bool IsOdd(const int i) noexcept
{
return i % 2 == 1; //Broken oddness check!
}
This implementation is broken, as it will not work for negative integers.