note 84511 added to function.abs

From: Date: Thu, 17 Jul 2008 08:12:55 +0000
Subject: note 84511 added to function.abs
Groups: php.notes 
Request: Send a blank email to php-notes+get-141604@lists.php.net to get a copy of this message
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? ---- Server IP: 82.177.164.100 Probable Submitter: 83.16.223.134 ---- Manual Page -- http://www.php.net/manual/en/function.abs.php Edit -- https://master.php.net/note/edit/84511 Del: integrated -- https://master.php.net/note/delete/84511/integrated Del: useless -- https://master.php.net/note/delete/84511/useless Del: bad code -- https://master.php.net/note/delete/84511/bad+code Del: spam -- https://master.php.net/note/delete/84511/spam Del: non-english -- https://master.php.net/note/delete/84511/non-english Del: in docs -- https://master.php.net/note/delete/84511/in+docs Del: other reasons-- https://master.php.net/note/delete/84511 Reject -- https://master.php.net/note/reject/84511 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141604) next »