From:             milahu89 at web dot de
Operating system: irrelevant
PHP version:      5.0.5
PHP Bug Type:     Math related
Bug description:  new function: sgn()

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 bug report at http://bugs.php.net/?id=35025&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=35025&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=35025&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=35025&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=35025&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=35025&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=35025&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=35025&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=35025&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=35025&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=35025&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=35025&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=35025&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=35025&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=35025&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=35025&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=35025&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=35025&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=35025&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=35025&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=35025&r=mysqlcfg

Reply via email to