SIGN scalar function

Returns an indicator of the sign of the argument.

Read syntax diagramSkip visual syntax diagramSIGN(expression)

The schema is SYSIBM. (The SYSFUN version of the SIGN function continues to be available.)

expression
An expression that returns a value of any built-in numeric data type. DECIMAL and REAL values are converted to double-precision floating-point numbers for processing by the function.

If the argument is less than zero, -1 is returned. If the argument is the decimal floating-point value of -0, the decimal floating-point value of -0 is returned. If argument equals zero, 0 is returned. If argument is greater than zero, 1 is returned.

The result of the function is:
  • SMALLINT if the argument is SMALLINT
  • INTEGER if the argument is INTEGER
  • BIGINT if the argument is BIGINT
  • DECFLOAT(n) if the argument is DECFLOAT(n)
  • DOUBLE otherwise.

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.
   VALUES SIGN(:PROFIT)
Returns the value 1.