<?php
int gmp_cmp ( GMP|int|string $num1, GMP|int|string $num2 )
where,
$num1 = The first GMP number to compare
$num2 = The second GMP number to compare
?>
<?php
// A new result is shown if you run
// this exercise several times
$a01a = [ '0x100', 256, '0400' ];
$a01b = mt_rand(255, 257);
foreach($a01a as $n01a)
{
$c01ab = gmp_cmp($n01a, $a01b);
echo 'gmp_cmp( ' . $n01a . ', ' . $a01b . ' ) = ' . $c01ab . '<br>';
}
?>
<?php
$a = 123123;
$b = -123123;
$c = "12345678900987654321";
$d = "12345678900987654321";
$e = "12345678900987654321";
$f = "123456789009876543211";
$g = 0;
$h = 0;
$i = 1231222;
$j = 0;
$k = 0;
$l = 345355;
$m0 = "827278512385463739";
$m1 = "827278512385463739";
var_dump(gmp_cmp($a,$b));
echo '<br><br>';
var_dump(gmp_cmp($c,$d));
echo '<br><br>';
var_dump(gmp_cmp($e, $f));
echo '<br><br>';
var_dump(gmp_cmp($g, $h));
echo '<br><br>';
var_dump(gmp_cmp($i, $j));
echo '<br><br>';
var_dump(gmp_cmp($k, $l));
echo '<br><br>';
$n0 = gmp_init($m0);
var_dump(gmp_cmp(0,$m0) < 0);
$n1 = gmp_init($m1);
var_dump(gmp_cmp($m1,$m0));
try {
var_dump(gmp_cmp(array(),array()));
} catch (\TypeError $e) {
echo $e->getMessage() . '<br><br>';
}
?>