
sign - sign of a real or complex expression

Calling sequence:
sign(x)

Parameter:

x  --   expression

Overloading:

All

Summary:

sign determines the sign of a real or complex expression. It is defined by x
/ abs(x) for x <> 0.

The function call sign(0) returns 0 by default, but the value of sign(0) can
be redefined by direct assignment.

If the type of x is one of DOM_INT, DOM_RAT or DOM_FLOAT then the kernel
function sign will be used to determine the sign of x. The return value of
this is -1 for negative signs, 1 for positive signs and 0 if the argument is zero.

If the argument is the floating point number 0.0 then 0 is returned if the
number is zero at all internal positions. In some cases a floating point number

that returns 0.0 can have internal digits unequal to zero.  (Internally more
positions are calculated as set with the environment variableDIGITS .)  In
this case the result is 1 or -1.

For expressions of the type DOM_EXPR the determination of the sign of an
expression can be defined under the function attribute "sign" in the form of
a procedure or function. If the operator of x has such an attribute then the
procedure or function under the entry of the attribute "sign" is called with
the operand of x and the result is returned.

If such a function attribute is not defined and the operator of x is one of the
function environments _plus, _mult or _power, then this is directly processed
by the function sign and the result is returned. In other cases the expression
sign(x) is returned.

>>  sign( -8/3 );

      -1

>>  sign( 2+3*I );

                - 1/2
      (2 + 3 I) 13

>>  sign( PI*x );

      sign(x)

>>  sign( exp(sin(2+3*I)) );

      exp((I) cos(2) sinh(3))

See also:  abs, funcattr

