Skip to main content

Sgn

Returns an integer indicating the sign of a number.

Synopsis

Sgn(number)

Arguments

The number argument can be any valid numeric expression.

Description

The Sgn function has the following return values:

If Number Is Sgn Returns
Greater than zero 1
Equal to zero 0
Less than zero –1

The sign of the number argument determines the return value of the Sgn function. If number is the empty string ("") or a non-numeric value, Sgn returns 0. Sgn resolves multiple sign values; for example, --7 is equivalent to +7, and thus returns 1.

Examples

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

Dim MyVar1, MyVar2, MyVar3
MyVar1 = 12: MyVar2 = -2.4: MyVar3 = 0
Println Sgn(MyVar1)    ' Returns 1.
Println Sgn(MyVar2)    ' Returns -1.
Println Sgn(MyVar3)    ' Returns 0.
Println Sgn("")        ' Returns 0.
Println Sgn("a")       ' Returns 0.

See Also

Purpose of this instance: Draft documentation
DocReleaseID: Core2018.1.11
Content loaded from:
/staging/ce/2018.1.11/doc/cache/en-us/src/
/staging/ce/2018.1.11/doc/ensemble/en-us/src/
/staging/ce/2018.1.11/doc/isp/en-us/src/
/staging/learning/zenmojo-doc/en-us/src/
FeedbackOpens in a new tab