|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-04-03 13:10 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 08:00:01 2025 UTC |
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 ...