Skip to content

Instantly share code, notes, and snippets.

@Lif3line
Created July 17, 2014 11:03
Show Gist options
  • Save Lif3line/1cae0bf64a49c48c1cba to your computer and use it in GitHub Desktop.
Save Lif3line/1cae0bf64a49c48c1cba to your computer and use it in GitHub Desktop.
Get the sign of a number as {-1,1} in C/C++
x = 1;
signX = (x >= 0) - (0 > x);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment