Skip to content

abs()#


Syntax
abs( number )

Description#

Returns the absolute value of the provided numeric expression. The function accepts integers and floating-point values (and expressions that evaluate to numeric values). The result is always non-negative.

Parameters#

Parameter Type Description
number number Numeric value or expression to compute the absolute value of

Returns#

number — absolute value of the argument (same numeric type semantics as the input).

Examples#

Integer input
<MvASSIGN NAME="l.val" VALUE="{ -42 }">
<MvASSIGN NAME="l.abs" VALUE="{ abs(l.val) }">
<MvEVAL EXPR="{ 'abs(-42) = ' $ l.abs }">
Floating point input
<MvASSIGN NAME="l.pi" VALUE="{ -3.14159 }">
<MvASSIGN NAME="l.abs_pi" VALUE="{ abs(l.pi) }">
<MvEVAL EXPR="{ 'abs(-3.14159) = ' $ l.abs_pi }">
Expression
<MvASSIGN NAME="l.result" VALUE="{ abs( ( -5 + 2 ) * 3 ) }">
<MvEVAL EXPR="{ l.result }">