This is documentation for Kohana v2.3.x.

Table of Contents
StatusDraft
TodoProof read

Number Helper

Provides methods for rounding integer numbers.

Methods

round()

num::round() accepts two arguments. An integer to round, and a nearest integer number to round too, defaults to 5.

Example

// Given an input of: $numbers = array(1,3,5,9,99,999);
<p>Rounding numbers to nearest 5</p>
<?php foreach ($numbers as $number): ?>
	<p>Round <?php echo $number ?> to <?php echo num::round($number, 5) ?> </p>
<?php endforeach ?>

This will output as HTML

<p>Rounding numbers to nearest 5</p>
	<p>Round 1 to 0 </p>
	<p>Round 3 to 5 </p>
	<p>Round 5 to 5 </p>
 
	<p>Round 9 to 10 </p>
	<p>Round 99 to 100 </p>
	<p>Round 999 to 1000 </p>