$c = bi_absmod(-1, $modulus); echo '-1 (mod $modulus) = [', bi_to_str($c), "]<br/>\n"; $c = bi_invmod($a, $modulus); echo '1 / $a (mod $modulus) = [', bi_to_str($c), "]<br/>\n"; $c = bi_sqrmod($a, $modulus); echo 'sqr($a) (mod $modulus) = [', bi_to_str($c), "]<br/>\n"; echo 'cmp($a, $b) (mod $modulus) = ', bi_cmpmod($a, $b, $modulus), "<br/>\n"; /* other functions */ echo '<h3>other functions</h3>' . "\n"; /* attention: second parameter of bi_pow() must have integer type (not BIG_INT!) */ $c = bi_pow($a, 4); echo 'pow($a, 4) = [', bi_to_str($c), "]<br/>\n"; // argument of bi_fact() must have integer type (not BIG_INT) $c = bi_fact(100); echo '100! = [', bi_to_str($c), "]<br/>\n"; $c = bi_sqrt($a); echo 'sqrt($a) = [', bi_to_str($c), "]<br/>\n"; $c = bi_sqrt_rem($a); echo 'sqrt_rem($a) = [', bi_to_str($c), "]<br/>\n"; $c = bi_gcd($a, $b); echo 'GCD($a, $b) = [', bi_to_str($c), "]<br/>\n"; // Miller-Rabin primality test of $a echo 'miller_test($a, $b) = ', bi_miller_test($a, $b), "<br/>\n"; // primality test of $a echo 'is_prime($a) = ', bi_is_prime($a), "<br/>\n"; // Jacobi symbol ($a|$b)
function bcpow($a, $b) { return bi_to_str(bi_pow($a, $b)); }
/** * Raise an arbitrary precision number to another * * @param string $base The left operand, as a string. * @param string $exp The right operand, as a string. * @access public * @return string Returns the result as a string. */ public function pow($base, $exp) { return bi_pow($base, $exp); }