The sign, or signum, function is defined by

It may be calculated with four instructions on most machines [Hop]:
![]()
If you don't have shift right signed, then use the substitute noted at the end of Section 2-6, giving the following nicely symmetric formula (five instructions):
![]()
Comparison predicate instructions permit a three-instruction solution, with either
![]()
Finally, we note that the formula 
almost works; it fails only for x = -231.