Skip to main content

$ZABS (ObjectScript)

Returns the absolute value of the given argument.

Synopsis

$ZABS(n)

Argument

Argument Description
n Any number.

Description

$ZABS returns the absolute value of n.

Argument

n

Any number. Can be specified as a value, a variable, or an expression. The expression is evaluated, and the result converted to a positive value. Multiple plus and minus signs are permitted. Leading and trailing zeros are deleted.

A non-numeric string is evaluated as 0. For evaluation of mixed numeric strings and non-numeric strings, refer to Strings As Numbers.

Example

The following example returns the absolute value of the number you supply:

   READ "Input a number: ",num
   SET abs=$ZABS(num)
   WRITE "The absolute value of ",num," is ",abs

See Also

FeedbackOpens in a new tab