Sgn() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Returns -1, 0, or 1, to indicate that a specified number is negative, zero, or positive (respectively). You can issue this statement from the MapBasic window in MapInfo Pro.

Syntax

Sgn( num_expr )

num_expr is a numeric expression.

Return Value

Float (-1, 0, or 1)

Description

The Sgn() function returns a value of -1 if the num_expr is less than zero, a value of 0 (zero) if num_expr is equal to zero, or a value of 1 (one) if num_expr is greater than zero.

Example

Dim x As Integer
x = Sgn(-0.5)

' x now has a value of -1

See Also:

Abs() function