/**
  * Compare two Math_Integer objects.
  * if $i1 > $i2, returns +1,
  * if $i1 == $i2, returns +0,
  * if $i1 < $i2, returns -1,
  *
  * @param object Math_Integer $int1
  * @param object Math_Integer $int2
  * @return mixed and integer on success, PEAR_Error otherwise
  * @access public
  * @see Math_IntegerOp::sign
  */
 function &compare(&$int1, &$int2)
 {
     /*{{{*/
     if (PEAR::isError($err = Math_IntegerOp::_validInts($int1, $int2))) {
         return $err;
     }
     switch (MATH_INTLIB) {
         /*{{{*/
         case 'gmp':
             $cmp = gmp_cmp($int1->getValue(), $int2->getValue());
             break;
         case 'bcmath':
             $cmp = bccomp($int1->getValue(), $int2->getValue());
             break;
         case 'std':
             $cmp = $int1->getValue() - $int2->getValue();
             break;
     }
     /*}}}*/
     return Math_IntegerOp::sign(new Math_Integer($cmp));
 }
    $i2 = new Math_Integer('11111');
}
$i3 = new Math_Integer(6);
echo '* Using lib: ' . MATH_INTLIB . "\n";
echo 'i1 = ' . $i1->toString() . "\n";
echo 'i2 = ' . $i2->toString() . "\n";
echo 'i3 = ' . $i3->toString() . "\n";
$res = Math_IntegerOp::add($i1, $i2);
echo 'i1 + i2 = ' . $res->toString() . "\n";
$res = Math_IntegerOp::sub($i1, $i2);
echo 'i1 - i2 = ' . $res->toString() . "\n";
$res = Math_IntegerOp::sub($i2, $i1);
echo 'i2 - i1 = ' . $res->toString() . "\n";
$res = Math_IntegerOp::mul($i1, $i2);
echo 'i1 * i2 = ' . $res->toString() . "\n";
$res = Math_IntegerOp::div($i1, $i3);
echo 'i1 / i3 = ' . $res->toString() . "\n";
$res = Math_IntegerOp::mod($i2, $i3);
echo 'i1 % i3 = ' . $res->toString() . "\n";
$res = Math_IntegerOp::neg($i1);
echo 'neg(i1) = ' . $res->toString() . "\n";
echo 'sign(neg(i1)) = ' . Math_IntegerOp::sign($res) . "\n";
echo 'sign(neg(0)) = ' . Math_IntegerOp::sign(new Math_Integer(0)) . "\n";
echo 'sign(i2) = ' . Math_IntegerOp::sign($i2) . "\n";
echo 'compare(i1, i2) = ' . Math_IntegerOp::compare($i1, $i2) . "\n";
echo 'compare(i3, i3) = ' . Math_IntegerOp::compare($i3, $i3) . "\n";
echo 'compare(i2, i1) = ' . Math_IntegerOp::compare($i2, $i1) . "\n";
$res = Math_IntegerOp::abs(Math_IntegerOp::neg($i2));
echo 'abs(neg(i2)) = ' . $res->toString() . "\n";
// vim: ts=4:sw=4:et:
// vim6: fdl=1: