<?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>Comments on: Integers in PHP, running with scissors, and portability</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/</link>
	<description>Percona&#039;s MySQL &#38; InnoDB performance and scalability blog</description>
	<lastBuildDate>Sat, 11 Feb 2012 16:45:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Christian Kruse</title>
		<link>http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/comment-page-1/#comment-567279</link>
		<dc:creator>Christian Kruse</dc:creator>
		<pubDate>Tue, 26 May 2009 12:01:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/#comment-567279</guid>
		<description>Hi,

the code you are using has a bug, since integer overflow handling is plattform dependent in PHP. I ran php -r &#039;var_dump((int)4294967296);&#039; on different plattforms, results vary:

- Mac OS X, Intel Core2Duo, 32bit: int(-1)
- Linux, Intel Celeron, 32bit: int(0)
- Linux, Intel Core2Duo, 64bit: int(4294967296)</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>the code you are using has a bug, since integer overflow handling is plattform dependent in PHP. I ran php -r &#8216;var_dump((int)4294967296);&#8217; on different plattforms, results vary:</p>
<p>- Mac OS X, Intel Core2Duo, 32bit: int(-1)<br />
- Linux, Intel Celeron, 32bit: int(0)<br />
- Linux, Intel Core2Duo, 64bit: int(4294967296)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PHP &#171; php</title>
		<link>http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/comment-page-1/#comment-349816</link>
		<dc:creator>PHP &#171; php</dc:creator>
		<pubDate>Thu, 28 Aug 2008 09:35:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/#comment-349816</guid>
		<description>[...] &#8220;Integers in PHP, running with scissors, and portability&#8220;. MySQL Performance Blog (27 March 2007). Retrieved on [...]</description>
		<content:encoded><![CDATA[<p>[...] &#8220;Integers in PHP, running with scissors, and portability&#8220;. MySQL Performance Blog (27 March 2007). Retrieved on [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sprazzi di LuciditÃ  &#187; links for 2008-07-25</title>
		<link>http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/comment-page-1/#comment-334099</link>
		<dc:creator>Sprazzi di LuciditÃ  &#187; links for 2008-07-25</dc:creator>
		<pubDate>Fri, 25 Jul 2008 00:37:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/#comment-334099</guid>
		<description>[...] Integers in PHP, running with scissors, and portability &#124; MySQL Performance Blog (tags: php integer bug) [...]</description>
		<content:encoded><![CDATA[<p>[...] Integers in PHP, running with scissors, and portability | MySQL Performance Blog (tags: php integer bug) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: markus</title>
		<link>http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/comment-page-1/#comment-332913</link>
		<dc:creator>markus</dc:creator>
		<pubDate>Tue, 22 Jul 2008 18:33:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/#comment-332913</guid>
		<description>These days I dont understand anyone that picks PHP instead of Ruby or Python.

PHP is only a success on the www, but other than that is crippled design are a huge problem.</description>
		<content:encoded><![CDATA[<p>These days I dont understand anyone that picks PHP instead of Ruby or Python.</p>
<p>PHP is only a success on the www, but other than that is crippled design are a huge problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kuroki Kaze</title>
		<link>http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/comment-page-1/#comment-332858</link>
		<dc:creator>Kuroki Kaze</dc:creator>
		<pubDate>Tue, 22 Jul 2008 15:41:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/#comment-332858</guid>
		<description>Damn.</description>
		<content:encoded><![CDATA[<p>Damn.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jared</title>
		<link>http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/comment-page-1/#comment-292047</link>
		<dc:creator>Jared</dc:creator>
		<pubDate>Fri, 02 May 2008 17:07:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/#comment-292047</guid>
		<description>If you don&#039;t expect a negative value return from unpack() then test for it, and add 0x100000000

	list(, $a) = unpack(&quot;N&quot;, &quot;\xff\xff\xff\xff&quot;);
	if ($a &lt; 0)
		$a += 0x100000000;

The add forces a float conversion, and corrects the sign.</description>
		<content:encoded><![CDATA[<p>If you don&#8217;t expect a negative value return from unpack() then test for it, and add 0&#215;100000000</p>
<p>	list(, $a) = unpack(&#8220;N&#8221;, &#8220;\xff\xff\xff\xff&#8221;);<br />
	if ($a &lt; 0)<br />
		$a += 0&#215;100000000;</p>
<p>The add forces a float conversion, and corrects the sign.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Improved Cacti monitoring templates for MySQL at Xaprb</title>
		<link>http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/comment-page-1/#comment-289141</link>
		<dc:creator>Improved Cacti monitoring templates for MySQL at Xaprb</dc:creator>
		<pubDate>Mon, 28 Apr 2008 00:43:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/#comment-289141</guid>
		<description>[...] script that gathers the data is totally rewritten from scratch, and much improved. For example, the math works on 32-bit systems. It has caching built-in so each poll cycle results in just one request to the server, instead of [...]</description>
		<content:encoded><![CDATA[<p>[...] script that gathers the data is totally rewritten from scratch, and much improved. For example, the math works on 32-bit systems. It has caching built-in so each poll cycle results in just one request to the server, instead of [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/comment-page-1/#comment-252475</link>
		<dc:creator>Xaprb</dc:creator>
		<pubDate>Thu, 13 Mar 2008 15:32:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/#comment-252475</guid>
		<description>I am trying to graph some InnoDB stats in Cacti, and must extract them from SHOW INNODB STATUS, which prints them as a hi/lo 64-bit unsigned number, of course.  I have to do some math on them to subtract one from the other.  I ended up just sending them back to MySQL and doing a SELECT, casting them to string at the same time:

&lt;code&gt;
         $sql = &quot;SELECT &quot;
              . &quot;CONCAT(&#039;&#039;, (($innodb_lsn[0] &lt;&lt; 32) + $innodb_lsn[1])) &quot;
              . &quot;AS log_bytes_written, &quot;
              . &quot;CONCAT(&#039;&#039;, (($flushed_to[0] &lt;&lt; 32) + $flushed_to[1])) &quot;
              . &quot;AS log_bytes_flushed, &quot;
              . &quot;CONCAT(&#039;&#039;, ((($innodb_lsn[0] &lt;&lt; 32) + $innodb_lsn[1]) &quot;
              . &quot;- (($flushed_to[0] &lt;&lt; 32) + $flushed_to[1]))) &quot;
              . &quot;AS unflushed_log&quot;; 
&lt;/code&gt;

Not high-performance, but the code sure is easy to write.</description>
		<content:encoded><![CDATA[<p>I am trying to graph some InnoDB stats in Cacti, and must extract them from SHOW INNODB STATUS, which prints them as a hi/lo 64-bit unsigned number, of course.  I have to do some math on them to subtract one from the other.  I ended up just sending them back to MySQL and doing a SELECT, casting them to string at the same time:</p>
<p><code><br />
         $sql = "SELECT "<br />
              . "CONCAT('', (($innodb_lsn[0] &lt;&lt; 32) + $innodb_lsn[1])) "<br />
              . "AS log_bytes_written, "<br />
              . "CONCAT('', (($flushed_to[0] &lt;&lt; 32) + $flushed_to[1])) "<br />
              . "AS log_bytes_flushed, "<br />
              . "CONCAT('', ((($innodb_lsn[0] &lt;&lt; 32) + $innodb_lsn[1]) "<br />
              . "- (($flushed_to[0] &lt;&lt; 32) + $flushed_to[1]))) "<br />
              . "AS unflushed_log";<br />
</code></p>
<p>Not high-performance, but the code sure is easy to write.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Comment on Integers in PHP, running with scissors, and portability&#8230;</title>
		<link>http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/comment-page-1/#comment-231088</link>
		<dc:creator>Comment on Integers in PHP, running with scissors, and portability&#8230;</dc:creator>
		<pubDate>Tue, 15 Jan 2008 17:12:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/#comment-231088</guid>
		<description>[...] Comment on Integers in PHP, running with scissors, and portability&#8230; &#8230;horrors of PHP, Iâ€™m just being an elitist old bitch, with my closures and namespaces and garbage collection which works properly, and what&#8230; [...]</description>
		<content:encoded><![CDATA[<p>[...] Comment on Integers in PHP, running with scissors, and portability&#8230; &#8230;horrors of PHP, Iâ€™m just being an elitist old bitch, with my closures and namespaces and garbage collection which works properly, and what&#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Synnott</title>
		<link>http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/comment-page-1/#comment-229700</link>
		<dc:creator>Robert Synnott</dc:creator>
		<pubDate>Fri, 11 Jan 2008 01:26:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/#comment-229700</guid>
		<description>&lt;strong&gt;Your PHP Hell&lt;/strong&gt;

I&#039;m sure that most of you think that when I rant and rave about the horrors of PHP, I&#039;m just being an elitist old bitch, with my closures and namespaces and garbage collection which works properly, and what-not. PHP is...</description>
		<content:encoded><![CDATA[<p><strong>Your PHP Hell</strong></p>
<p>I&#8217;m sure that most of you think that when I rant and rave about the horrors of PHP, I&#8217;m just being an elitist old bitch, with my closures and namespaces and garbage collection which works properly, and what-not. PHP is&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

