Sgn Function

Returns an integer indicating the sign of a number.

Syntax

Sgn(number)

Arguments: The number argument can be any valid numeric expression.

Return Value: The Sgn function has the following return values:

Table 11-14 Sgn Function Return Values

Is Value
Greater than Zero 1
Equal to Zero 0
Less than Zero -1

Remarks

The sign of the number argument determines the return value of the Sgn function.

The following example uses the Sgn function to determine the sign of a number:

Example:

Dim MyVar1, MyVar2, MyVar3, MySign
MyVar1 = 12: MyVar2 = -2.4: MyVar3 = 0
MySign = Sgn(MyVar1)   
' Output: 1.
MySign = Sgn(MyVar2)   
' Output: -1.
MySign = Sgn(MyVar3)  
' Output: 0.