Sgn Function

Purpose

Returns the sign of a numeric expression.

Syntax

iexp = Sgn(x)

x:aexp

Example

Debug.Show

Trace Sgn(-210)         // Prints -1

Trace Sgn(Abs(5 - 10))  // Prints 1

Trace Sgn(0)            // Prints 0

Remarks

The value returned by the Sgn() function depends on the sign of the argument x:

x < 0 returns -1,

x = 0 returns 0 and

x > 0 returns 1.

See Also

Abs()

{Created by Sjouke Hamstra; Last updated: 23/10/2014 by James Gaite}