sgn/2 gives the integer --1 if Number is negative, 0 if it is zero and 1 if it is greater than zero. It is always true that
X =:= sgn(X) * abs(X)In coroutining mode, if Number is a free variable, the call to sgn/2 is delayed until this variable is instantiated.
Success: sgn(42, 1). sgn(-5, Result). (gives Result = -1) sgn(-6.2, Result). (gives Result = -1) sgn(0.0, 0). Fail: sgn(1, 0). Error: sgn(A, 6). (Error 4). sgn(1, 1.0). (Error 5). sgn(4 + 2, 6). (Error 24). sgn(1, r). (Error 24).