Text Documents (Writer)
HTML Documents (Writer Web)
Spreadsheets (Calc)
Presentations (Impress)
Drawings (Draw)
Database Functionality (Base)
Formulae (Math)
Charts and Diagrams
Macros and Scripting
Office Installation
Common Help Topics
OneOffice Logo

Sgn Function

Returns an integer number +1, 0 or -1 indicating whether the number that is passed to the function is positive, zero or negative respectively.

Syntax:


Sgn (Number)

Return value:

Integer

Parameters:

Number: Numeric expression that determines the value that is returned by the function.

Number Return value
negative Sgn returns -1.
0 Sgn returns 0.
positive Sgn returns 1.

Error codes:

5 Invalid procedure call

Example:


Sub ExampleSgn
    Print sgn(-10) ' returns -1
    Print sgn(0) ' returns 0
    Print sgn(10) ' returns 1
End Sub