Beispiel #1
0
    Converts string representation of $num from base $base_from to $base_to
*/
$num = '-12345678900987654321';
echo 'Decimal number [', $num, '] equals to [', bi_base_convert($num, 10, 36), '] by base 36', "<br/>\n";
/*
    basic functions
*/
echo '<h3>basic functions</h3>' . "\n";
$c = bi_add($a, $b);
echo '$a + $b = [', bi_to_str($c), "]<br/>\n";
$c = bi_sub($a, $b);
echo '$a - $b = [', bi_to_str($c), "]<br/>\n";
$c = bi_mul($a, $b);
echo '$a * $b = [', bi_to_str($c), "]<br/>\n";
$c = bi_div($a, $b);
echo '$a / $b = [', bi_to_str($c), "]<br/>\n";
$c = bi_mod($a, $b);
echo '$a % $b = [', bi_to_str($c), "]<br/>\n";
$c = bi_abs($a);
echo 'abs($a) = [', bi_to_str($c), "]<br/>\n";
$c = bi_neg($a);
echo 'neg($a) = [', bi_to_str($c), "]<br/>\n";
$c = bi_inc($a);
echo 'inc($a) = [', bi_to_str($c), "]<br/>\n";
$c = bi_dec($a);
echo 'dec($a) = [', bi_to_str($c), "]<br/>\n";
$c = bi_sqr($a);
echo 'sqr($a) = [', bi_to_str($c), "]<br/>\n";
echo 'cmp($a, $b) = ', bi_cmp($a, $b), "<br/>\n";
echo 'cmp_abs($a, $b) = ', bi_cmp_abs($a, $b), "<br/>\n";
Beispiel #2
0
 function bcdiv($a, $b)
 {
     return bi_to_str(bi_div($a, $b));
 }
 /**
  * Divide two arbitrary precision numbers
  *
  * @param string $a The left operand, as a string.
  * @param string $b The right operand, as a string.
  * @access public
  * @return string|null Returns the result of the division as a string, or <b>NULL</b> if right_operand is 0.
  */
 public function div($a, $b)
 {
     return bi_div($a, $b);
 }