Skip to content

Instantly share code, notes, and snippets.

@luuhq
Created March 17, 2013 01:04
Show Gist options
  • Save luuhq/5179077 to your computer and use it in GitHub Desktop.
Save luuhq/5179077 to your computer and use it in GitHub Desktop.
Shitty way of testing if a number is even
public bool IsEven(int num)
{
int up = num;
int down = num;
try
{
while(up != 0)
{
up = up + 2;
}
return true;
}
catch(OverflowException)
{
}
try
{
while(down != 0)
{
down = down - 2;
}
return true;
}
catch(OverflowException)
{
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment