IB Statements/sgn

From CometWiki

< IB Statements
Revision as of 10:26, 22 May 2009 by Badge (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

SGN function

Syntax: SGN(numeric-argument)

Discussion: The SGN function returns the sign (positive, negative or zero) of a numeric value according to the following chart:

Numeric-argument    Value returned  
==================================
positive                 1
zero                     0
negative                 1-

The numeric-argument may be a numeric constant, a single-element numeric variable, a numeric array element, a numeric expression, or a numeric function.

The intermediate result of the SGN function is stored in a numeric accumulator with a length and precision of 16.0 If this intermediate result is moved to a receiving numeric variable, its precision is automatically adjusted to the defined precision of that variable.

Example: A = SGN(B)

In the above example, the sign of the value stored in the variable B is moved to the variable A. For example, if B equals 25, A will equal 1. Likewise, if B equals -25, A will equal -1, and if B equals 0, A will also equal 0.

Personal tools