logo
Home XtGem- Templates- XtScript- bottom
Rounds up or down a floating point number
[...] = optional ... = your value
[var $... = ]call round $num=…[;$mode=…][;$precision=…]
$precision = The optional number of decimal digits to round to.
$mode = what happens to a half(.5)
one of the following
PHP_ROUND_HALF_UP ; default action
PHP_ROUND_HALF_DOWN
PHP_ROUND_HALF_EVEN ; round to the even number
PHP_ROUND_HALF_ODD ; round to the odd number
Show in textarea
<!--parser:xtscript-->
var $input = 12345.55
var $precision=1
var $output = call round $num=$input; $precision=$precision
print input = $input<br />
print output = $output<hr />

var $input = 12345.55
var $precision=-3
var $output = call round $num=$input; $precision=$precision
print input = $input<br />
print output = $output<hr />
  
var $input = 12345.55
var $precision=1
var $mode=PHP_ROUND_HALF_DOWN
var $output = call round $num=$input; $mode=$mode; $precision=$precision
print input = $input<br />
print output = $output
<!--/parser:xtscript-->
Show in textarea
Reload
input = 12345.55
output = 12345.6
input = 12345.55
output = 12000
input = 12345.55
output = 12345.5
Powered by XtGem
About us Contact Forum top