Wonder if there are any nontrivial ways of finding number\'s sign (signum function)?
May be shorter / faster / more elegant solutions than the obvious one
I just was about to ask the same question, but came to a solution before i was finished writing, saw this Question already existed, but didn't saw this solution.
(n >> 31) + (n > 0)
it seems to be faster by adding a ternary though (n >> 31) + (n>0?1:0)