Scripting > 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(Val)
Parameters
Val
Type: Double
A numeric value.
(return)
Type: Long
1, 0, or -1, depending on whether Val is positive, 0, or negative.
Remarks
If the current data value is NULL, Val 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