System Functions

ABS( )

Absolute Value

Format

ABS(num[,ERR=stmtref])
 
Where:

num

Numeric expression whose absolute value is to be returned.

stmtref

Program line number or statement label to which to transfer control.

Returns

Numeric, absolute value of expression. Always positive or zero.

Description

The ABS( ) function returns the absolute value of the numeric expression num. The value returned is a positive numeric value or zero.

For example, the absolute value of the numeric expression (X) is returned as follows:

ABS (X) ... If X>0 ... Returns X
 
ABS (X) ... If X<0 ... Returns X * -1 (positive result)
 
ABS (X) ... If X=0 ... Returns X (zero)

Example

input "Give me your first number ",X
input "Give me another one ",Y
print "The difference is ",abs(X-Y)

->run
Give me your first number 12.345
Give me another one 23.456
The difference is 11.111