<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>I am Zef &#187; fail</title>
	<atom:link href="http://zef.me/tag/fail/feed" rel="self" type="application/rss+xml" />
	<link>http://zef.me</link>
	<description>Technology, Me, You.</description>
	<lastBuildDate>Mon, 30 Aug 2010 13:30:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<atom:link rel='hub' href='http://zef.me/?pushpress=hub'/>
		<item>
		<title>The opposite of abs()</title>
		<link>http://zef.me/2097/the-opposite-of-abs</link>
		<comments>http://zef.me/2097/the-opposite-of-abs#comments</comments>
		<pubDate>Thu, 27 Aug 2009 13:04:49 +0000</pubDate>
		<dc:creator>Zef</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[fail]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zef.me/?p=2097</guid>
		<description><![CDATA[A gem from the comments on the (otherwise pretty good)  [...]]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://us.php.net/manual/en/function.abs.php#58508">gem from the comments on the (otherwise pretty good) PHP manual</a> on the abs() function:</p>

<blockquote>Sometimes you may want to do the opposite of abs(): turn a positive number into a negative.

<span style="color: #0000bb; background-color: transparent;">&lt;?php</span>

<span style="color: #007700; background-color: transparent;">function </span><span style="color: #0000bb; background-color: transparent;">turn_neg </span><span style="color: #007700; background-color: transparent;">(</span><span style="color: #0000bb; background-color: transparent;">$num</span><span style="color: #007700; background-color: transparent;">) {
return </span><span style="color: #0000bb; background-color: transparent;">$num </span><span style="color: #007700; background-color: transparent;">- </span><span style="color: #0000bb; background-color: transparent;">$num </span><span style="color: #007700; background-color: transparent;">* </span><span style="color: #0000bb; background-color: transparent;">2</span><span style="color: #007700; background-color: transparent;">;
}</span>

<span style="color: #0000bb; background-color: transparent;">?&gt;
</span>
But this can create errors when you put a negative number inside&#8230;

turn_neg (-2) returns 6.

<span style="color: #0000bb; background-color: transparent;">&lt;?php</span>

turn_neg <span style="color: #007700; background-color: transparent;">(-</span><span style="color: #0000bb; background-color: transparent;">2</span><span style="color: #007700; background-color: transparent;">); </span><span style="color: #ff8000; background-color: transparent;">// 6.</span>

<span style="color: #0000bb; background-color: transparent;">?&gt;
</span>
The solution is to make another function to determine if the number is negative or not.

<span style="color: #0000bb; background-color: transparent;">&lt;?php</span>

<span style="color: #007700; background-color: transparent;">function </span><span style="color: #0000bb; background-color: transparent;">is_neg </span><span style="color: #007700; background-color: transparent;">(</span><span style="color: #0000bb; background-color: transparent;">$num</span><span style="color: #007700; background-color: transparent;">) {
return </span><span style="color: #0000bb; background-color: transparent;">$num </span><span style="color: #007700; background-color: transparent;">&lt; </span><span style="color: #0000bb; background-color: transparent;">0</span><span style="color: #007700; background-color: transparent;">;
}</span>

function <span style="color: #0000bb; background-color: transparent;">turn_neg </span><span style="color: #007700; background-color: transparent;">(</span><span style="color: #0000bb; background-color: transparent;">$num</span><span style="color: #007700; background-color: transparent;">) {
if (</span><span style="color: #0000bb; background-color: transparent;">is_neg </span><span style="color: #007700; background-color: transparent;">(</span><span style="color: #0000bb; background-color: transparent;">$num</span><span style="color: #007700; background-color: transparent;">)) {
return </span><span style="color: #0000bb; background-color: transparent;">$num </span><span style="color: #007700; background-color: transparent;">- </span><span style="color: #0000bb; background-color: transparent;">$num </span><span style="color: #007700; background-color: transparent;">* </span><span style="color: #0000bb; background-color: transparent;">2</span><span style="color: #007700; background-color: transparent;">;
} else {
return </span><span style="color: #0000bb; background-color: transparent;">abs </span><span style="color: #007700; background-color: transparent;">(</span><span style="color: #0000bb; background-color: transparent;">$num</span><span style="color: #007700; background-color: transparent;">);
}
}</span>

<span style="color: #0000bb; background-color: transparent;">turn_neg </span><span style="color: #007700; background-color: transparent;">(</span><span style="color: #0000bb; background-color: transparent;">2</span><span style="color: #007700; background-color: transparent;">); </span><span style="color: #ff8000; background-color: transparent;">// -2
</span><span style="color: #0000bb; background-color: transparent;">turn_neg </span><span style="color: #007700; background-color: transparent;">(-</span><span style="color: #0000bb; background-color: transparent;">2</span><span style="color: #007700; background-color: transparent;">); </span><span style="color: #ff8000; background-color: transparent;">// 2</span>

<span style="color: #0000bb; background-color: transparent;">?&gt;
</span>
Or, if the number is not negative, you could also return false.</blockquote>

<p>Although this is a clear demonstration of little reflection on what is really the simplest way of achieving this, I can somehow appreciate the enthusiasm with which the author describes his &#8220;inventive&#8221; solution. It works, but a simple <code>-1*abs($num)</code> would have worked just as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://zef.me/2097/the-opposite-of-abs/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Google Flags Internet as Malware</title>
		<link>http://zef.me/1807/google-flags-internet-as-malware</link>
		<comments>http://zef.me/1807/google-flags-internet-as-malware#comments</comments>
		<pubDate>Sun, 01 Feb 2009 16:38:58 +0000</pubDate>
		<dc:creator>Zef</dc:creator>
				<category><![CDATA[Main]]></category>
		<category><![CDATA[fail]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://zef.me/2009/02/google-flags-internet-as-malware/</guid>
		<description><![CDATA[Somebody at Googlie made littlie mistakie! Woopsie! [...]]]></description>
			<content:encoded><![CDATA[<p style="clear: both">Somebody <a href="http://www.techcrunch.com/2009/01/31/google-flags-whole-internet-as-malware/">at Googlie made littlie mistakie</a>! <a href="http://googleblog.blogspot.com/2009/01/this-site-may-harm-your-computer-on.html">Woopsie</a>!<br /><br /></p>

<p style="clear: both"><a href="http://zef.me/wp-content/uploads/2009/02/googlemalware2.jpg" class="image-link"><img class="linked-to-original" src="http://zef.me/wp-content/uploads/2009/02/googlemalware1.jpg" height="308" width="380" style=" text-align: center; display: block; margin: 0 auto 10px;" /></a></p>

<p><br class="final-break" style="clear: both" /></p>
]]></content:encoded>
			<wfw:commentRss>http://zef.me/1807/google-flags-internet-as-malware/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fail fabrication fail</title>
		<link>http://zef.me/1774/fail-fabrication-fail</link>
		<comments>http://zef.me/1774/fail-fabrication-fail#comments</comments>
		<pubDate>Tue, 27 Jan 2009 14:09:03 +0000</pubDate>
		<dc:creator>Zef</dc:creator>
				<category><![CDATA[Main]]></category>
		<category><![CDATA[fail]]></category>

		<guid isPermaLink="false">http://zef.me/?p=144</guid>
		<description><![CDATA[On one of my favorite blogs, FAIL Blog failed miserably [...]]]></description>
			<content:encoded><![CDATA[<p>On one of my favorite blogs, <a href="http://failblog.org/2009/01/27/denial-fail/">FAIL Blog</a> failed miserably:</p>

<p><img class="alignnone size-full wp-image-145" title="failfabricationfail" src="http://zef.me/wp-content/uploads/2009/01/failfabricationfail.png" alt="failfabricationfail" width="506" height="296" /></p>

<p>The red lines are from the FAIL blog, the blue one is mine. Either the submitter of this fail post really got the real-time web working, or he posted it himself 1 second earlier. FAIL!</p>

<p>(Credit for noticing this goes to <a href="http://www.lclnet.nl/">my colleague</a>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://zef.me/1774/fail-fabrication-fail/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->