fdim - This function returns the positive difference between the 2 var chosen by the user.
fdim (x,y)
This mathematical function returns the positive difference between x and y. Y has to be equal or higher than x, otherwise it will return zero. It gives the answer to Y-X.
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={_{fdim(3,10);}}.),q(res=7.)); test(q(res={_{fdim(10,3);}}.),q(res=0.)); With floats: test(q(res={_{fdim(2.5,3);}}.),q(res=.5.)); One can use this function with another variable: test(q(res={_{ %include "/includes/extenso.sn"; a=3; fdim(a,4); }}.), q(res=1.)); With a trigonometric function: test(q(res={_{ %include "/includes/extenso.sn"; a=cos(0); fdim(0,a); }}.), q(res=1.)); With negative numbers: test(q(res={_{fdim(-3,2);}}.),q(res=5.)); One can also consider the limits: test(q(res={_{fdim(-INF,INF);}}.),q(res=0.)); With an array, it simply considers its number of elements: test(q(res={_{fdim(1,[1,2]);}}.),q(res=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