fabs - This function computes the absolute value of a float.
fabs (argument)
This mathematical function allows the user to compute the absolute value of a float. The absolute value is equivalent to the modulo of the number, its positive value. It resemblances a distance. If the argument is a float or an integer, the function will simply return its positive value.
Note: In the followings examples, the _ between the { should be removed to make it work.
One can use this function with integers:
test(q(res={_{fabs(-2);}}.),q(res=2.));
test(q(res={_{fabs(2);}}.),q(res=2.));
With floats:
test(q(res={_{fabs(-999.9);}}.),q(res=999.9.));
With defined variables:
test(q(res={_{
%include "/includes/extenso.sn";
fabs(-PI);
}}.),
q(res=PI.));
One another variable:
test(q(res={_{
%include "/includes/extenso.sn";
a=-3.1;
fabs(a);
}}.),
q(res=3.1.));
With a trigonometric function :
test(q(res={_{
%include "/includes/extenso.sn";
a=cos(PI);
fabs(a);
}}.),
q(res=1.));
With an array:
test(q(res={_{fabs(-1,2.5,-2.5);}}.),q(res=\[1,2.5,2.5\].));
Written by Caroline Laplante, <claplante@sednove.com>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
1.0 2014-09-09 21:24:14 laplante@sednove.com