<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1019840" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1019840</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/php-maths#comment-1120803</link>
    <description> &lt;p&gt;Yup..&lt;/p&gt;
&lt;p&gt;round() will round to the nearest integer, unless you specify a precission (decimal places to keep).&lt;/p&gt;
&lt;p&gt;ceil() round up to higher integer. no args.&lt;br /&gt;
floor() round to lower integer. no args.&lt;/p&gt;
 </description>
     <pubDate>Fri, 06 Dec 2002 07:38:03 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1120803 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/php-maths#comment-1120775</link>
    <description> &lt;p&gt;Thanks guys, nike_guy_man it&#039;s a vote form value thing, but to keep the number size down in the db I&#039;m using -2, -1, 0, 1, 2 for the vote values then the values get added or subtracted from the old value and divided by the amount of values - if that makes sense.&lt;/p&gt;
&lt;p&gt;Mark I&#039;ll give that a go tonight after work, thanks&lt;/p&gt;
&lt;p&gt;I did some searching last night, anyone every use &#039;round&#039; or &#039;ceil&#039; or &#039;floor&#039;&lt;/p&gt;
 </description>
     <pubDate>Thu, 05 Dec 2002 21:34:55 +0000</pubDate>
 <dc:creator>Busy</dc:creator>
 <guid isPermaLink="false">comment 1120775 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/php-maths#comment-1120734</link>
    <description> &lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$a &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$b&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;===&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;) ? &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;0 &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;: (int) &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$b &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;/ &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$c&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
IF $b equals 0 (and is same datatype, numeric) THEN&lt;br /&gt;
$a = 0;&lt;br /&gt;
ELSE&lt;br /&gt;
$a = (int) $b / $c;&lt;br /&gt;
ENDIF&lt;/p&gt;
 </description>
     <pubDate>Thu, 05 Dec 2002 15:34:09 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1120734 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/php-maths#comment-1120710</link>
    <description> &lt;p&gt;It is a mathematical law that you can&#039;t divide a number by 0, but you can divide 0 by a number. Makes sense doesn&#039;t it??&lt;br /&gt;
So just remove the value of 0 for the variables... what exactly is their need here?&lt;/p&gt;
 </description>
     <pubDate>Thu, 05 Dec 2002 13:50:35 +0000</pubDate>
 <dc:creator>nike_guy_man</dc:creator>
 <guid isPermaLink="false">comment 1120710 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/php-maths#comment-1120700</link>
    <description> &lt;p&gt;Ok everything was going fine until I added a new entry (value of 0) now it&#039;s giving me a php warning:&lt;/p&gt;
&lt;p&gt;Warning: Division by zero in c:\phpdev\....&lt;/p&gt;
&lt;p&gt;anyway around this warning (short of turning error warnings off &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt; )&lt;br /&gt;
I tried all four methods mentioned above&lt;/p&gt;
&lt;p&gt;I&#039;m using negative, zero and postive numbers&lt;/p&gt;
&lt;p&gt;b = whole numbers 0 ++ (no neagatives)&lt;br /&gt;
c = whole range (--1, 0, 1++)&lt;/p&gt;
&lt;p&gt;a = c / b so insome cases the anser could be negative&lt;/p&gt;
 </description>
     <pubDate>Thu, 05 Dec 2002 08:38:01 +0000</pubDate>
 <dc:creator>Busy</dc:creator>
 <guid isPermaLink="false">comment 1120700 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/php-maths#comment-1120360</link>
    <description> &lt;p&gt;Thanks &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Sun, 01 Dec 2002 20:54:53 +0000</pubDate>
 <dc:creator>Busy</dc:creator>
 <guid isPermaLink="false">comment 1120360 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/php-maths#comment-1120356</link>
    <description> &lt;p&gt;Or, you could type cast...&lt;br /&gt;
$a = (int) $b / $c;&lt;/p&gt;
&lt;p&gt;or...&lt;br /&gt;
$a = &lt;a href=&quot;http://www.php.net/manual/en/function.intval.php&quot; class=&quot;bb-url&quot;&gt;intval&lt;/a&gt;($b/$c);&lt;/p&gt;
&lt;p&gt;To do this with sprintf, you&#039;d use:&lt;br /&gt;
$a = sprintf(&quot;%d&quot;, $b/$c);&lt;/p&gt;
&lt;p&gt;The problem with sprintf is that you&#039;ve changed the datatype from a numeric (int, double, float, etc.) to a string.  This isn&#039;t as big of a problem with PHP as it handles variant datatypes, but you&#039;ll have problems doing this in C/C++.&lt;/p&gt;
 </description>
     <pubDate>Sun, 01 Dec 2002 19:59:18 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1120356 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/php-maths#comment-1120344</link>
    <description> &lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;//The 0 is how many decimals you want.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$a &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;number_format&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$b &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;/ &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$c&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
 </description>
     <pubDate>Sun, 01 Dec 2002 11:28:52 +0000</pubDate>
 <dc:creator>zollet</dc:creator>
 <guid isPermaLink="false">comment 1120344 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
