docs.intersystems.com
Home  /  Application Development: Core Topics  /  InterSystems SQL Reference  /  SQL Functions  /  SIGN


InterSystems SQL Reference
SIGN
[Back]  [Next] 
InterSystems: The power behind what matters   
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.
SIGN returns the SMALLINT data type.
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 InterSystems 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