Developer Documentation Library > UNICOM Intelligence Function Library > Mathematical functions > Sgn
 
Sgn
Returns an integer that indicates the sign of a number. The function returns 1 if the number is greater than 0, 0 if it is equal to 0, and -1 if it is less than zero.
Syntax
Sgn(<value>)
Parameters
<value>
Type: Double
A numeric value.
(return)
Type: Long
1, 0, or -1, depending on whether <value> is positive, 0, or negative.
Notes
If the current data value is NULL, <value> is 0.0 and the return value is 0.
This function is similar to the Sgn function in VBScript.
Example
The following mrScriptBasic example uses the Sgn function to determine the sign of a number:
Dim Positive, Zero, Negative
Positive = Sgn(50.05) ' Returns 1
Zero = Sgn(0) ' Returns 0
Negative = Sgn(-10) ' Returns -1
See also
Mathematical functions