SIGN
Synopsis
SIGN(numeric-expression) {fn SIGN(numeric-expression)}
Arguments
Argument | Description |
---|---|
numeric-expression | A number for which the sign is to be returned. |
Description
SIGN returns the following:
-
-1 if numeric-expression is less than zero.
-
0 (zero) if numeric-expression is zero: 0, +0, or -0.
-
1 if numeric-expression is greater than zero.
-
NULL if numeric-expression is NULL, or if it is a non-numeric string.
SIGN can be used as either an ODBC scalar function (with the curly brace syntax) or as an SQL general function.
SIGN converts numeric-expression to canonical form before determining its value. For example, SIGN(-+-+3) and SIGN(-3+5) both return 1, indicating a positive number.
In Caché SQL, two negative signs (hyphens) are the in-line comment indicator. For this reason, a SIGN argument specifying two successive negative signs must be presented as a numeric string enclosed in quotes.
Examples
The following examples shows the effects of SIGN:
SELECT SIGN(-49) AS PosNeg
returns -1.
SELECT {fn SIGN(-0.0)} AS PosNeg
returns 0.
SELECT SIGN(-+-16.748) AS PosNeg
returns 1.
SELECT {fn SIGN(NULL)} AS PosNeg
returns <null>.
See Also
-
+(Positive) and –(Negative) unary operators
-
ABS function
-
ISNUMERIC function