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

Wymagane. Legalne wyrażenie numeryczne.

Jeśli liczba jest:

  • >0 - Sgn zwróci 1.
  • <0 - Sgn zwróci -1.
  • =0 - Sgn zwróci 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