round - Standart rounding of a number.
round(argument)
This mathematical function returns the nearest integer of the argument. It does not take the sign into account.
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={_{round(-5);}}.),q(res=-5.));
With floats (negative or positive):
test(q(res={_{round(-4.5);}}.),q(res=-5.));
test(q(res={_{round(4.5);}}.),q(res=5.));
With another variable:
test(q(res={_{
%include "/includes/extenso.sn";
a=2.6;
round(a);
}}.),
q(res=3.));
With a trigonometric function:
test(q(res={_{
%include "/includes/extenso.sn";
a=cos(PI);
round(a);
}}.),
q(res=-1.));
With an array:
test(q(res={_{round(4.3,-4.3,1.5);}}.),q(res=\[4,-4,2\].));
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