Skip to content

Instantly share code, notes, and snippets.

@dobrokot
Created April 10, 2015 00:35
Show Gist options
  • Save dobrokot/0de3f031951988484f71 to your computer and use it in GitHub Desktop.
Save dobrokot/0de3f031951988484f71 to your computer and use it in GitHub Desktop.
int f(int x) {
if (x == 0)
return 0;
int sign = x < 0 ? -1 : 1;
return ((x&1) ? -x : +x) - sign;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment