<?xml version="1.0" encoding="windows-1252"?>
<node id="24343" title="Answer: How do I round a number?" created="2000-07-25 20:22:31" updated="2005-08-11 06:15:47">
<type id="1888">
categorized answer</type>
<author id="11732">
QandAEditors</author>
<data>
<field name="doctext">
The guy asked to round a number, the simplest way
is (my highschool teacher would be proud now..):

&lt;code&gt;$rounded = int ( $orig + 0.5 )&lt;/code&gt;

&lt;br&gt;
This approach floors any decimal portion less than 0.5, and rounds up (in value) any decimal portion greater than .5.  That means the following:
&lt;code&gt;
 1.1 rounds to 1.0.
 1.5 rounds to 2.0.
-1.1 rounds to 1.0.
-1.5 rounds to 1.0.
&lt;/code&gt;
</field>
<field name="parent_node">
24335</field>
</data>
</node>
