trunc . math . sncode
latest
This function returns the nearest integer not greater in magnitude than the argument.
TRUNC
NAME
trunc - This function returns the nearest integer not greater in magnitude than the argument.
SYNOPSIS
trunc(argument)
DESCRIPTION
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.
PARAMETERS
- number
- Specify the number (float) used as argument for the trunc function.
RETURN
- The nearest integer not greater in magnitude than the argument
EXAMPLES
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\].));
AUTHOR
Written by Caroline Laplante, <claplante@sednove.com>