Last active
July 23, 2018 16:57
-
-
Save ivand58/0ea08f14bb18138e59bfb388979d03ba to your computer and use it in GitHub Desktop.
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
\ LONG VERSION | |
: sign_ ( x -- sign(x) | |
?dup if | |
0> if 1 else -1 then | |
else 0 then ; | |
\ SHORT VERSION | |
: sig dup if 0> if 1 else -1 then then ; | |
\ more optimized | |
: sig dup 0< over 0 > negate + ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment