📅  最后修改于: 2023-12-03 15:33:32.931000             🧑  作者: Mango
gmp_com()函数是PHP中的gmp扩展提供的函数之一,用来比较两个GMP数的大小关系。
gmp_com ( GMP|int|string $num1 , GMP|int|string $num2 )
$num1 = gmp_init(123456789);
$num2 = gmp_init(987654321);
$compare = gmp_com($num1, $num2);
switch($compare) {
case -1:
echo "num1 is less than num2";
break;
case 0:
echo "num1 is equal to num2";
break;
case 1:
echo "num1 is greater than num2";
break;
}
输出结果:num1 is less than num2(因为123456789 < 987654321)。