note 26550 deleted from function.bccomp by nlopess

From: Date: Thu, 18 Dec 2003 09:51:38 +0000
Subject: note 26550 deleted from function.bccomp by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-62166@lists.php.net to get a copy of this message
Note Submitter: victorvalley@gmx.net ---- Use the bccomp() function like this: if ($result=(bccomp($number1,$number2)) < 0){   // What to do if $number1 is lower than $number2 } else if ($result > 0) {   // What to do if $number1 is greater than $number2 } else {   // Guess what this will do?   // This will happen if $number1 equals $number2! } This could be done in a different way with switch-case as well: switch (bccomp($number1,$number2)){   case -1: // $number1 < $number2 break; case 0: // $number1 == $number2 break; case 1: // $number1 > $number2 break; } You don't have to set all 3 cases but it makes this example look longer :)

« previous php.notes (#62166) next »