SIGN

The SIGN function returns an indicator of the sign of the argument.

Read syntax diagram
>>-SIGN(numeric-expression)------------------------------------><

The schema is SYSIBM.

The returned value is one of the following values:
-1
if the argument is less than zero
- 0
if the argument is DECFLOAT negative zero
0
if the argument is zero
1
if the argument is greater than zero

The argument must be an expression that returns a value of any built-in numeric data type, except DECIMAL(31,31).

Start of changeThe argument can also be a character string or graphic string data type. The string input is implicitly cast to a numeric value of DECFLOAT(34).End of change

The result has the same data type and length attribute as the argument, except that precision is increased by one if the argument is DECIMAL and the scale of the argument is equal to its precision. For example, an argument with a data type of DECIMAL(5,5) will result in DECIMAL(6,5).

The result can be null; if the argument is null, the result is the null value.

Example: Assume that host variable PROFIT is a large integer with a value of 50000.
   SELECT SIGN(:PROFIT)
     FROM SYSIBM.SYSDUMMY1;
This example returns the value 1.