note 84511 deleted from function.abs by danbrown

From: Date: Thu, 17 Jul 2008 14:14:22 +0000
Subject: note 84511 deleted from function.abs by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-141624@lists.php.net to get a copy of this message
Note Submitter: Ister ---- jeremys indicated one thing - there is no sgn function wich actually seems a bit strange for me. Of course it is as simple as possible, but it is usefull and it is a standard math function needed occasionally. Well, I have solved this function in a bit different matter: <?php function sgn($x) { if($x>0) $x=1; else if($x<0) $x=-1; else if($x!=0) $x=null; return $x; } ?> The difference is that it returns null when the argument isn't a number at all. Any better ideas?

« previous php.notes (#141624) next »