note 57463 added to function.bccomp

From: Date: Tue, 04 Oct 2005 22:41:41 +0000
Subject: note 57463 added to function.bccomp
Groups: php.notes 
Request: Send a blank email to php-notes+get-96395@lists.php.net to get a copy of this message
I slapped together min() and max() functions using bccomp(). While min() and max() only take an arbitrary number of args (i.e. max(1, 5, 1235, 12934, 66)) bccomp only takes 2. Note that this doesn't take into account $scale. <?php function bcmax() { $max = null; foreach(func_get_args() as $value) { if ($max == null) { $max = $value; } else if (bccomp($max, $value) < 0) { $max = $value; } } return $max; } function bcmin() { $min = null; foreach(func_get_args() as $value) { if ($min == null) { $min = $value; } else if (bccomp($min, $value) > 0) { $min = $value; } } return $min; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.bccomp.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57463 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57463&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57463&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57463&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57463&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57463&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57463&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57463&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57463&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#96395) next »