Loading

ABS

math

Computes the absolute value of a number value.

The ABS function consumes a numeric value from the top of the stack and pushes back its absolute value.

Since 2.6.0, this function can be applied to a list of numeric values. In this case, the function is applied to each element of the list thus returning a list.

Since 2.7.1, this fonction can be also applied to a GTS. In this case, the function is applied to each value of the given GTS, returning a new GTS.

ABS is available since version 1.0.0.

See also

Signatures

Examples

42 ABS -42 ABS 3.14 ABS -3.14 ABS 0 ABS -0 ABS NaN ABS
[ -42 42 21 -45 ] ABS
NEWGTS 1 NaN NaN NaN 2 ADDVALUE 2 NaN NaN NaN -20 ADDVALUE 3 NaN NaN NaN 21 ADDVALUE 4 NaN NaN NaN -12 ADDVALUE 5 NaN NaN NaN 42 ADDVALUE 6 NaN NaN NaN -7 ADDVALUE ABS

Examples

return [ ABS(42), ABS(-42), ABS(3.14), ABS(-3.14), ABS(0), ABS(-0), ABS(NaN) ]
return ABS( [ -42, 42, 21, -45 ] )
gts = NEWGTS() ADDVALUE(gts, 1, NaN, NaN, NaN, 2) ADDVALUE(gts, 2, NaN, NaN, NaN, -20) ADDVALUE(gts, 3, NaN, NaN, NaN, 21) ADDVALUE(gts, 4, NaN, NaN, NaN, -12) ADDVALUE(gts, 5, NaN, NaN, NaN, 42) ADDVALUE(gts, 6, NaN, NaN, NaN, -7) return ABS(gts)