Introduction | Language Structure | IB Statements | File System | Comet 32 Runtime | Index |
Syntax: | ABS(numeric-argument) |
Discussion: |
The ABS function returns the absolute value of a numeric
argument. "Absolute value" is the magnitude of a numeric value,
regardless of the sign of the value. Thus, the result of the ABS
function will always be a positive number or zero.
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 ABS function is stored in an accumulator with the same precision as the numeric-argument. If this intermediate result is moved to a receiving numeric variable, its precision is automatically adjusted to the defined precision of that variable. |
Example 1: |
A = ABS(B)
In the above example, the absolute value of numeric variable B is stored in numeric variable A. For example, if B equals -27, then A equals 27 (the absolute value of -27). |
Example 2: |
ON ABS(X) GOTO 100,200,300,400,500
In this example, the integer portion of the numeric variable X is used as the control variable for the ON/GOTO statement. For example, if X equals -1, the absolute value equals 1, and the ON/GOTO statement will transfer the program to statement label 300. |