trunc - This function returns the nearest integer not greater in magnitude than the argument.
trunc(argument)
This mathematical function returns the nearest integer value of the argument, but it is also not greater than the magnitude of the argument. It returns the value without regard of its sign.
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={_{trunc(-4);}}.),q(res=-4.)); With floats (negative or positive): test(q(res={_{trunc(-4.5);}}.),q(res=-4.)); test(q(res={_{trunc(4.5);}}.),q(res=4.)); With another variable: test(q(res={_{ %include "/includes/extenso.sn"; a=2.6; trunc(a); }}.), q(res=2.)); With a trigonometric function: test(q(res={_{ %include "/includes/extenso.sn"; a=cos(PI); trunc(a); }}.), q(res=-1.)); With a string: test(q(res={_{trunc(4.3,-4.3,1.5);}}.),q(res=\[4,-4,1\].));
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