<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Kommentare zu: PHP: floor() and ceil() are slow!</title>
	<atom:link href="http://juliusbeckmann.de/blog/php-floor-and-ceil-are-slow.html/feed" rel="self" type="application/rss+xml" />
	<link>http://juliusbeckmann.de/blog/php-floor-and-ceil-are-slow.html</link>
	<description>Ich bin nicht verrückt, nur technisch begabt ...</description>
	<lastBuildDate>Fri, 26 Sep 2014 12:04:55 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Von: Half Truth</title>
		<link>http://juliusbeckmann.de/blog/php-floor-and-ceil-are-slow.html/comment-page-1#comment-672</link>
		<dc:creator>Half Truth</dc:creator>
		<pubDate>Thu, 25 Mar 2010 21:06:22 +0000</pubDate>
		<guid isPermaLink="false">http://juliusbeckmann.de/blog/?p=494#comment-672</guid>
		<description>&quot;So by symptoms, these two methods are equivalent.&quot;
=&gt; That is wrong!

If the PHP floor is a real floor function it will produce following reuslt: 
floor( -1.2 ) = -2

If (int) does really cut, as you said, it will produce following result:
(int)-1.8 = -1

Your testimony should only count for positive values!


To confuse you even more:
in VB the funktion Fix() does cut like (int) here,
but the function Int() there ia a floor() - so don&#039;t mix it up! ;)
Oh, and there is no ceil() in VB, it has to be produced with -Int(-x)</description>
		<content:encoded><![CDATA[<p>"So by symptoms, these two methods are equivalent."<br />
=&gt; That is wrong!</p>
<p>If the PHP floor is a real floor function it will produce following reuslt:<br />
floor( -1.2 ) = -2</p>
<p>If (int) does really cut, as you said, it will produce following result:<br />
(int)-1.8 = -1</p>
<p>Your testimony should only count for positive values!</p>
<p>To confuse you even more:<br />
in VB the funktion Fix() does cut like (int) here,<br />
but the function Int() there ia a floor() - so don't mix it up! ;)<br />
Oh, and there is no ceil() in VB, it has to be produced with -Int(-x)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Von: Robert</title>
		<link>http://juliusbeckmann.de/blog/php-floor-and-ceil-are-slow.html/comment-page-1#comment-559</link>
		<dc:creator>Robert</dc:creator>
		<pubDate>Fri, 15 Jan 2010 14:29:51 +0000</pubDate>
		<guid isPermaLink="false">http://juliusbeckmann.de/blog/?p=494#comment-559</guid>
		<description>You are right. The function call in PHP is really slow. You should avoid function calls where ever you can, if you have to build a performant application. This idea can be lead to use language constructs for everything. For example use $str[$i] instead of substr($str, $i, 1). But if you have to loop over arrays, it is a better idea to use prefabricated functions.

The problem with numbers out of the range of int should be known when the app is developed. So it is possible to use either the fast int cast or the slower floor(). You have to keep in mind, that this is a benchmark. In general the floor() is only called once (if it is not inside of a loop).</description>
		<content:encoded><![CDATA[<p>You are right. The function call in PHP is really slow. You should avoid function calls where ever you can, if you have to build a performant application. This idea can be lead to use language constructs for everything. For example use $str[$i] instead of substr($str, $i, 1). But if you have to loop over arrays, it is a better idea to use prefabricated functions.</p>
<p>The problem with numbers out of the range of int should be known when the app is developed. So it is possible to use either the fast int cast or the slower floor(). You have to keep in mind, that this is a benchmark. In general the floor() is only called once (if it is not inside of a loop).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
