Caché SQL Reference
SIGN
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Class Reference   
Search:    

A numeric function that returns the sign of a given numeric expression.
Synopsis
SIGN(numeric-expression)

{fn SIGN(numeric-expression)}
Arguments
numeric-expression A number for which the sign is to be returned.
Description
SIGN returns the following:
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.
Note:
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