docs.intersystems.com
Home / InterSystems SQL Reference / SQL Functions / SIGN


InterSystems SQL Reference
SIGN
Previous section           Next section
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


Previous section           Next section
View this book as PDF
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-02-21 22:53:07