VBScript Sgn Function

Definition and Usage

The Sgn function can return an integer indicating the sign of the specified number.

Syntax

Sgn(number)
Parameter Description
number

Required. A valid numeric expression.

If the number is:

  • >0 - Sgn will return 1.
  • <0 - Sgn will return -1.
  • =0 - Sgn will return 0.

Example

Example 1

document.write(Sgn(15))

Output:

1

Example 2

document.write(Sgn(-5.67)) 

Output:

-1

Example 3

document.write(Sgn(0))

Output:

0