Round()

Rounds a number to the closest integer. If rounding to a specific number of decimals is needed, use the precision attribute to define the number of decimals to be rounded to.

Round( number=number, precision=number );

Returns: Number

Argument Description Default
number
number, required

Number to round

precision
number, optional

Number of decimal points to round to

0

Examples

var pi = 3.1415926535;
	var pi_rounded = Round(pi, 2);
<span class="nf">echo</span><span class="p">(</span><span class="nv">pi</span><span class="p">);</span> <span class="c">// 3.1415926535</span>
<span class="nf">echo</span><span class="p">(</span><span class="s1">&#39;&lt;br&gt;&#39;</span><span class="p">);</span>
<span class="nf">echo</span><span class="p">(</span><span class="nv">pi_rounded</span><span class="p">);</span> <span class="c">// 3.14</span>

See also