abs . math . sncode
latest
this function computes the absolute value
ABS(1e)
NAME
abs - this function computes the absolute value
SYNOPSIS
abs(var);
DESCRIPTION
The abs() function computes the absolute value of a number. This means that it converts the var to a positive number, taking the non-negative value without regard to its sign. It resembles a distance and is, in fact, the modulus of the number. If var is a string, then the string is converted to a double. If var is a complex object, all items within the objects are returned as absolute values. A deep copy of the object is returned..
EXAMPLES
Note: In the followings examples, the _ between the { should be removed to make it work. One can use this function with floats: res={_{abs(2.5); }}. return res=2.5. res={_{abs(-2.5); }}. return res=2.5. With strings: res={_{abs("-2.5"); }}. return res=2.5. With integers: res={_{abs(2); }}. return res=2. res={_{abs(-2); }}. return res=2. With arrays: res={_{abs([-2, 2, 2.5, -2.5]); }}. return res=[2,2,2.5,2.5]. res={_{a=[-2, 2, 2.5, -2.5]; abs(a); a;}}. return res=[2,2,2.5,2.5][-2,2,2.5,-2.5]. res={_{a=[-2, 2, 2.5, { x : -2.5 } ]; abs(a); a;}}. return res=[2,2,2.5,{"x":2.5}][-2,2,2.5,{"x":-2.5}].
AUTHOR
Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>