ROUND
NAME
round - Standart rounding of a number.
SYNOPSIS
round(number[, decimal:integer])
DESCRIPTION
This mathematical function returns the nearest integer of the argument. It does not take the sign into account.
from version 5.167 the parameter specidfy the number of decimal from 0 to 10.
PARAMETERS
- number
- Specify the number (float) used as argument for the round function.
RETURN
- The nearest integer of 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={_{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\].));
round(3.1415926535, decimal:2); return 3.14
round([5.5, -5.5,3.1415926535, -3.99], decimal:2); return res=[5.5,-5.5,3.14,-3.99].
round([5.5, -5.5], [3.1415926535, -3.99], decimal:0);
round([5.5, -5.5,3.1415926535, -3.99], decimal:2);
return [[6,-6],[3,-4]][5.5,-5.5,3.14,-3.99]
round(null, decimal:2);
round(undefined, decimal:2);
round(true, decimal:2);
round(false, decimal:2);
round(3.14159265351234568, decimal:10);
return 00103.14159265
a=round({"x1" : [5.5, -5.5,3.1415926535, -3.99], "y1": 2.7182818}, decimal:2);
a.x1;a.y1
return [5.5,-5.5,3.14,-3.99]2.72
SEE ALSO
{{ include("includes/maths.sn") }}
AUTHOR
Written by Caroline Laplante, <claplante@sednove.com>
MODIFICATIONS
1.0 2014-09-09 21:24:14 laplante@sednove.com
Edit