Created
July 17, 2014 11:03
-
-
Save Lif3line/1cae0bf64a49c48c1cba to your computer and use it in GitHub Desktop.
Get the sign of a number as {-1,1} in C/C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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