#35025 [Opn->WFx]: new function: sgn()
| From: | tony2001@php.net | Date: | Mon, 03 Apr 2006 11:10:36 +0000 |
| Subject: | #35025 [Opn->WFx]: new function: sgn() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-95263@lists.php.net to get a copy of this message | ||
ID: 35025
Updated by: tony2001@php.net
Reported By: milahu89 at web dot de
-Status: Open
+Status: Wont fix
Bug Type: Feature/Change Request
Operating System: irrelevant
PHP Version: 5.0.5
New Comment:
It's easy to implement with the code you've provided.
No need for yet another one rarely used core function.
Previous Comments:
------------------------------------------------------------------------
[2005-10-30 17:10:01] milahu89 at web dot de
Description:
------------
not really a bug, but i'd like to suggest a new math-function sgn().
it would make comparison of integer values much easier (an nicer, of
course ;)).
i've attached an example in the srccode part.
Reproduce code:
---------------
<?php
// comparison with if/else :
if($a < $b) print("a < b");
elseif($a == $b) print("a == b");
else print("a > b");
// comparison with sgn() :
function sgn($int) {
if($int > 0) return 1;
if($int < 0) return -1;
return 0;
}
switch(sgn($a-$b)){
case 1: print("a > b");
case 0: print("a == b");
case -1: print("a < b");
}
?>
Expected result:
----------------
depends ;)
Actual result:
--------------
depends ...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35025&edit=1