Math::BigInt v1.87 take 8
authorTels <nospam-abuse@bloodgate.com>
Sat, 9 Jun 2007 14:07:34 +0000 (16:07 +0200)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Mon, 11 Jun 2007 15:20:38 +0000 (15:20 +0000)
Message-Id: <200706091407.36659@bloodgate.com>

p4raw-id: //depot/perl@31365

lib/Math/BigFloat.pm
lib/Math/BigInt.pm
lib/Math/BigInt/t/bare_mbf.t
lib/Math/BigInt/t/bare_mbi.t
lib/Math/BigInt/t/bigfltpm.inc
lib/Math/BigInt/t/bigfltpm.t
lib/Math/BigInt/t/bigintpm.inc
lib/Math/BigInt/t/bigintpm.t
lib/Math/BigInt/t/sub_mbf.t
lib/Math/BigInt/t/sub_mbi.t
lib/Math/BigInt/t/with_sub.t

index dbc929d..bc4ca90 100644 (file)
@@ -603,11 +603,11 @@ sub badd
   # return result as BFLOAT
 
   # set up parameters
-  my ($self,$x,$y,$a,$p,$r) = (ref($_[0]),@_);
+  my ($self,$x,$y,@r) = (ref($_[0]),@_);
   # objectify is costly, so avoid it
   if ((!ref($_[0])) || (ref($_[0]) ne ref($_[1])))
     {
-    ($self,$x,$y,$a,$p,$r) = objectify(2,@_);
+    ($self,$x,$y,@r) = objectify(2,@_);
     }
  
   return $x if $x->modify('badd');
@@ -629,11 +629,13 @@ sub badd
     return $x;
     }
 
-  return $upgrade->badd($x,$y,$a,$p,$r) if defined $upgrade &&
+  return $upgrade->badd($x,$y,@r) if defined $upgrade &&
    ((!$x->isa($self)) || (!$y->isa($self)));
 
+  $r[3] = $y;                                          # no push!
+
   # speed: no add for 0+y or x+0
-  return $x->bround($a,$p,$r) if $y->is_zero();                # x+0
+  return $x->bround(@r) if $y->is_zero();              # x+0
   if ($x->is_zero())                                   # 0+y
     {
     # make copy, clobbering up x (modify in place!)
@@ -641,7 +643,7 @@ sub badd
     $x->{_es} = $y->{_es};
     $x->{_m} = $MBI->_copy($y->{_m});
     $x->{sign} = $y->{sign} || $nan;
-    return $x->round($a,$p,$r,$y);
+    return $x->round(@r);
     }
  
   # take lower of the two e's and adapt m1 to it to match m2
@@ -678,7 +680,7 @@ sub badd
     }
 
   # delete trailing zeros, then round
-  $x->bnorm()->round($a,$p,$r,$y);
+  $x->bnorm()->round(@r);
   }
 
 # sub bsub is inherited from Math::BigInt!
@@ -1510,9 +1512,8 @@ sub is_int
   # return true if arg (BFLOAT or num_str) is an integer
   my ($self,$x) = ref($_[0]) ? (undef,$_[0]) : objectify(1,@_);
 
-  return 1 if ($x->{sign} =~ /^[+-]$/) &&      # NaN and +-inf aren't
-    $x->{_es} eq '+';                          # 1e-1 => no integer
-  0;
+  (($x->{sign} =~ /^[+-]$/) &&                 # NaN and +-inf aren't
+   ($x->{_es} eq '+')) ? 1 : 0;                        # 1e-1 => no integer
   }
 
 sub is_zero
@@ -1520,8 +1521,7 @@ sub is_zero
   # return true if arg (BFLOAT or num_str) is zero
   my ($self,$x) = ref($_[0]) ? (undef,$_[0]) : objectify(1,@_);
 
-  return 1 if $x->{sign} eq '+' && $MBI->_is_zero($x->{_m});
-  0;
+  ($x->{sign} eq '+' && $MBI->_is_zero($x->{_m})) ? 1 : 0;
   }
 
 sub is_one
@@ -1530,10 +1530,10 @@ sub is_one
   my ($self,$x,$sign) = ref($_[0]) ? (undef,@_) : objectify(1,@_);
 
   $sign = '+' if !defined $sign || $sign ne '-';
-  return 1
-   if ($x->{sign} eq $sign && 
-    $MBI->_is_zero($x->{_e}) && $MBI->_is_one($x->{_m})); 
-  0;
+
+  ($x->{sign} eq $sign && 
+   $MBI->_is_zero($x->{_e}) &&
+   $MBI->_is_one($x->{_m}) ) ? 1 : 0; 
   }
 
 sub is_odd
@@ -1541,9 +1541,9 @@ sub is_odd
   # return true if arg (BFLOAT or num_str) is odd or false if even
   my ($self,$x) = ref($_[0]) ? (undef,$_[0]) : objectify(1,@_);
   
-  return 1 if ($x->{sign} =~ /^[+-]$/) &&              # NaN & +-inf aren't
-    ($MBI->_is_zero($x->{_e}) && $MBI->_is_odd($x->{_m})); 
-  0;
+  (($x->{sign} =~ /^[+-]$/) &&         # NaN & +-inf aren't
+   ($MBI->_is_zero($x->{_e})) &&
+   ($MBI->_is_odd($x->{_m}))) ? 1 : 0; 
   }
 
 sub is_even
@@ -1551,23 +1551,21 @@ sub is_even
   # return true if arg (BINT or num_str) is even or false if odd
   my ($self,$x) = ref($_[0]) ? (undef,$_[0]) : objectify(1,@_);
 
-  return 0 if $x->{sign} !~ /^[+-]$/;                  # NaN & +-inf aren't
-  return 1 if ($x->{_es} eq '+'                                # 123.45 is never
-     && $MBI->_is_even($x->{_m}));                     # but 1200 is
-  0;
+  (($x->{sign} =~ /^[+-]$/) &&                 # NaN & +-inf aren't
+   ($x->{_es} eq '+') &&                       # 123.45 isn't
+   ($MBI->_is_even($x->{_m}))) ? 1 : 0;                # but 1200 is
   }
 
-sub bmul 
+sub bmul
   { 
-  # multiply two numbers -- stolen from Knuth Vol 2 pg 233
-  # (BINT or num_str, BINT or num_str) return BINT
+  # multiply two numbers
   
   # set up parameters
-  my ($self,$x,$y,$a,$p,$r) = (ref($_[0]),@_);
+  my ($self,$x,$y,@r) = (ref($_[0]),@_);
   # objectify is costly, so avoid it
   if ((!ref($_[0])) || (ref($_[0]) ne ref($_[1])))
     {
-    ($self,$x,$y,$a,$p,$r) = objectify(2,@_);
+    ($self,$x,$y,@r) = objectify(2,@_);
     }
 
   return $x if $x->modify('bmul');
@@ -1585,19 +1583,101 @@ sub bmul
     return $x->binf() if ($x->{sign} =~ /^-/ && $y->{sign} =~ /^-/);
     return $x->binf('-');
     }
-  # handle result = 0
-  return $x->bzero() if $x->is_zero() || $y->is_zero();
   
-  return $upgrade->bmul($x,$y,$a,$p,$r) if defined $upgrade &&
+  return $upgrade->bmul($x,$y,@r) if defined $upgrade &&
+   ((!$x->isa($self)) || (!$y->isa($self)));
+
+  # aEb * cEd = (a*c)E(b+d)
+  $MBI->_mul($x->{_m},$y->{_m});
+  ($x->{_e}, $x->{_es}) = _e_add($x->{_e}, $y->{_e}, $x->{_es}, $y->{_es});
+
+  $r[3] = $y;                          # no push!
+
+  # adjust sign:
+  $x->{sign} = $x->{sign} ne $y->{sign} ? '-' : '+';
+  $x->bnorm->round(@r);
+  }
+
+sub bmuladd
+  { 
+  # multiply two numbers and add the third to the result
+  
+  # set up parameters
+  my ($self,$x,$y,$z,@r) = (ref($_[0]),@_);
+  # objectify is costly, so avoid it
+  if ((!ref($_[0])) || (ref($_[0]) ne ref($_[1])))
+    {
+    ($self,$x,$y,$z,@r) = objectify(3,@_);
+    }
+
+  return $x if $x->modify('bmuladd');
+
+  return $x->bnan() if (($x->{sign} eq $nan) ||
+                       ($y->{sign} eq $nan) ||
+                       ($z->{sign} eq $nan));
+
+  # inf handling
+  if (($x->{sign} =~ /^[+-]inf$/) || ($y->{sign} =~ /^[+-]inf$/))
+    {
+    return $x->bnan() if $x->is_zero() || $y->is_zero(); 
+    # result will always be +-inf:
+    # +inf * +/+inf => +inf, -inf * -/-inf => +inf
+    # +inf * -/-inf => -inf, -inf * +/+inf => -inf
+    return $x->binf() if ($x->{sign} =~ /^\+/ && $y->{sign} =~ /^\+/);
+    return $x->binf() if ($x->{sign} =~ /^-/ && $y->{sign} =~ /^-/);
+    return $x->binf('-');
+    }
+
+  return $upgrade->bmul($x,$y,@r) if defined $upgrade &&
    ((!$x->isa($self)) || (!$y->isa($self)));
 
   # aEb * cEd = (a*c)E(b+d)
   $MBI->_mul($x->{_m},$y->{_m});
   ($x->{_e}, $x->{_es}) = _e_add($x->{_e}, $y->{_e}, $x->{_es}, $y->{_es});
 
+  $r[3] = $y;                          # no push!
+
   # adjust sign:
   $x->{sign} = $x->{sign} ne $y->{sign} ? '-' : '+';
-  return $x->bnorm()->round($a,$p,$r,$y);
+
+  # z=inf handling (z=NaN handled above)
+  $x->{sign} = $z->{sign}, return $x if $z->{sign} =~ /^[+-]inf$/;
+
+  # take lower of the two e's and adapt m1 to it to match m2
+  my $e = $z->{_e};
+  $e = $MBI->_zero() if !defined $e;           # if no BFLOAT?
+  $e = $MBI->_copy($e);                                # make copy (didn't do it yet)
+
+  my $es;
+
+  ($e,$es) = _e_sub($e, $x->{_e}, $z->{_es} || '+', $x->{_es});
+
+  my $add = $MBI->_copy($z->{_m});
+
+  if ($es eq '-')                              # < 0
+    {
+    $MBI->_lsft( $x->{_m}, $e, 10);
+    ($x->{_e},$x->{_es}) = _e_add($x->{_e}, $e, $x->{_es}, $es);
+    }
+  elsif (!$MBI->_is_zero($e))                  # > 0
+    {
+    $MBI->_lsft($add, $e, 10);
+    }
+  # else: both e are the same, so just leave them
+
+  if ($x->{sign} eq $z->{sign})
+    {
+    # add
+    $x->{_m} = $MBI->_add($x->{_m}, $add);
+    }
+  else
+    {
+    ($x->{_m}, $x->{sign}) = 
+     _e_add($x->{_m}, $add, $x->{sign}, $z->{sign});
+    }
+
+  # delete trailing zeros, then round
+  $x->bnorm()->round(@r);
   }
 
 sub bdiv 
@@ -2324,6 +2404,37 @@ sub bpow
   $x->round($a,$p,$r,$y);
   }
 
+sub bmodpow
+  {
+  # takes a very large number to a very large exponent in a given very
+  # large modulus, quickly, thanks to binary exponentation. Supports
+  # negative exponents.
+  my ($self,$num,$exp,$mod,@r) = objectify(3,@_);
+
+  return $num if $num->modify('bmodpow');
+
+  # check modulus for valid values
+  return $num->bnan() if ($mod->{sign} ne '+'           # NaN, - , -inf, +inf
+                       || $mod->is_zero());
+
+  # check exponent for valid values
+  if ($exp->{sign} =~ /\w/)
+    {
+    # i.e., if it's NaN, +inf, or -inf...
+    return $num->bnan();
+    }
+
+  $num->bmodinv ($mod) if ($exp->{sign} eq '-');
+
+  # check num for valid values (also NaN if there was no inverse but $exp < 0)
+  return $num->bnan() if $num->{sign} !~ /^[+-]$/;
+
+  # $mod is positive, sign on $exp is ignored, result also positive
+
+  # XXX TODO: speed it up when all three numbers are integers
+  $num->bpow($exp)->bmod($mod);
+  }
+
 ###############################################################################
 # trigonometric functions
 
@@ -2403,6 +2514,10 @@ sub bpi
   # rendundand operations ( like *= 1 ) were removed.
 
   my ($self,$n) = @_;
+  if (@_ == 0)
+    {
+    $self = $class;
+    }
   if (@_ == 1)
     {
     # called like Math::BigFloat::bpi(10);
@@ -2867,7 +2982,6 @@ sub import
 sub bnorm
   {
   # adjust m and e so that m is smallest possible
-  # round number according to accuracy and precision settings
   my ($self,$x) = ref($_[0]) ? (undef,$_[0]) : objectify(1,@_);
 
   return $x if $x->{sign} !~ /^[+-]$/;         # inf, nan etc
@@ -2881,18 +2995,18 @@ sub bnorm
       {
       if ($MBI->_acmp($x->{_e},$z) >= 0)
         {
-        $x->{_e} = $MBI->_sub  ($x->{_e}, $z);
+        $x->{_e} = $MBI->_sub ($x->{_e}, $z);
         $x->{_es} = '+' if $MBI->_is_zero($x->{_e});
         }
       else
         {
-        $x->{_e} = $MBI->_sub  ( $MBI->_copy($z), $x->{_e});
+        $x->{_e} = $MBI->_sub ( $MBI->_copy($z), $x->{_e});
         $x->{_es} = '+';
         }
       }
     else
       {
-      $x->{_e} = $MBI->_add  ($x->{_e}, $z);
+      $x->{_e} = $MBI->_add ($x->{_e}, $z);
       }
     }
   else
@@ -3071,6 +3185,7 @@ Math::BigFloat - Arbitrary size floating point math package
 
   $x->bmod($y);                        # modulus ($x % $y)
   $x->bpow($y);                        # power of arguments ($x ** $y)
+  $x->bmodpow($exp,$mod);      # modular exponentation (($num**$exp) % $mod))
   $x->blsft($y, $n);           # left shift by $y places in base $n
   $x->brsft($y, $n);           # right shift by $y places in base $n
                                # returns (quo,rem) or quo if in scalar context
@@ -3393,6 +3508,14 @@ Calculate PI to N digits (including the 3 before the dot).
 
 This method was added in v1.87 of Math::BigInt (June 2007).
 
+=head2 bmuladd()
+
+       $x->bmuladd($y,$z);             
+
+Multiply $x by $y, and then add $z to the result.
+
+This method was added in v1.87 of Math::BigInt (June 2007).
+
 =head1 Autocreating constants
 
 After C<use Math::BigFloat ':constant'> all the floating point constants
index 10aeb1b..ea4876c 100644 (file)
@@ -1513,7 +1513,7 @@ sub is_int
 
 sub bmul 
   { 
-  # multiply two numbers -- stolen from Knuth Vol 2 pg 233
+  # multiply the first number by the second numbers
   # (BINT or num_str, BINT or num_str) return BINT
 
   # set up parameters
@@ -1553,6 +1553,82 @@ sub bmul
   $x->round(@r);
   }
 
+sub bmuladd
+  { 
+  # multiply two numbers and then add the third to the result
+  # (BINT or num_str, BINT or num_str, BINT or num_str) return BINT
+
+  # set up parameters
+  my ($self,$x,$y,$z,@r) = (ref($_[0]),@_);
+  # objectify is costly, so avoid it
+  if ((!ref($_[0])) || (ref($_[0]) ne ref($_[1])))
+    {
+    ($self,$x,$y,$z,@r) = objectify(3,@_);
+    }
+
+  return $x if $x->modify('bmuladd');
+
+  return $x->bnan() if  ($x->{sign} eq $nan) ||
+                       ($y->{sign} eq $nan) ||
+                       ($z->{sign} eq $nan);
+
+  # inf handling of x and y
+  if (($x->{sign} =~ /^[+-]inf$/) || ($y->{sign} =~ /^[+-]inf$/))
+    {
+    return $x->bnan() if $x->is_zero() || $y->is_zero();
+    # result will always be +-inf:
+    # +inf * +/+inf => +inf, -inf * -/-inf => +inf
+    # +inf * -/-inf => -inf, -inf * +/+inf => -inf
+    return $x->binf() if ($x->{sign} =~ /^\+/ && $y->{sign} =~ /^\+/); 
+    return $x->binf() if ($x->{sign} =~ /^-/ && $y->{sign} =~ /^-/); 
+    return $x->binf('-');
+    }
+  # inf handling x*y and z
+  if (($z->{sign} =~ /^[+-]inf$/))
+    {
+    # something +-inf => +-inf
+    $x->{sign} = $z->{sign}, return $x if $z->{sign} =~ /^[+-]inf$/;
+    }
+
+  return $upgrade->bmuladd($x,$upgrade->new($y),$upgrade->new($z),@r)
+   if defined $upgrade && (!$y->isa($self) || !$z->isa($self) || !$x->isa($self));
+  # TODO: what it $y and $z have A or P set?
+  $r[3] = $z;                          # no push here
+
+  $x->{sign} = $x->{sign} eq $y->{sign} ? '+' : '-'; # +1 * +1 or -1 * -1 => +
+
+  $x->{value} = $CALC->_mul($x->{value},$y->{value});  # do actual math
+  $x->{sign} = '+' if $CALC->_is_zero($x->{value});    # no -0
+
+  my ($sx, $sz) = ( $x->{sign}, $z->{sign} );          # get signs
+
+  if ($sx eq $sz)  
+    {
+    $x->{value} = $CALC->_add($x->{value},$z->{value});        # same sign, abs add
+    }
+  else 
+    {
+    my $a = $CALC->_acmp ($z->{value},$x->{value});    # absolute compare
+    if ($a > 0)                           
+      {
+      $x->{value} = $CALC->_sub($z->{value},$x->{value},1); # abs sub w/ swap
+      $x->{sign} = $sz;
+      } 
+    elsif ($a == 0)
+      {
+      # speedup, if equal, set result to 0
+      $x->{value} = $CALC->_zero();
+      $x->{sign} = '+';
+      }
+    else # a < 0
+      {
+      $x->{value} = $CALC->_sub($x->{value}, $z->{value}); # abs sub
+      }
+    }
+  $x->round(@r);
+  }
+
 sub _div_inf
   {
   # helper function that handles +-inf cases for bdiv()/bmod() to reuse code
@@ -1731,7 +1807,7 @@ sub bmodinv
 sub bmodpow
   {
   # takes a very large number to a very large exponent in a given very
-  # large modulus, quickly, thanks to binary exponentation.  supports
+  # large modulus, quickly, thanks to binary exponentation. Supports
   # negative exponents.
   my ($self,$num,$exp,$mod,@r) = objectify(3,@_);
 
@@ -2947,6 +3023,8 @@ Math::BigInt - Arbitrary size integer/float math package
   $x->bdiv($y);                # divide, set $x to quotient
                        # return (quo,rem) or quo if scalar
 
+  $x->bmuladd($y,$z);  # $x = $x * $y + $z
+
   $x->bmod($y);                   # modulus (x % y)
   $x->bmodpow($exp,$mod);  # modular exponentation (($num**$exp) % $mod))
   $x->bmodinv($mod);      # the inverse of $x in the given modulus $mod
@@ -3447,6 +3525,14 @@ but faster.
 
        $x->bmul($y);                   # multiplication (multiply $x by $y)
 
+=head2 bmuladd()
+
+       $x->bmuladd($y,$z);
+
+Multiply $x by $y, and then add $z to the result,
+
+This method was added in v1.87 of Math::BigInt (June 2007).
+
 =head2 bdiv()
 
        $x->bdiv($y);                   # divide, set $x to quotient
index b2f1fd0..7428535 100644 (file)
@@ -27,7 +27,7 @@ BEGIN
     }
   print "# INC = @INC\n";
 
-  plan tests => 2070;
+  plan tests => 2200;
   }
 
 use Math::BigFloat lib => 'BareCalc';
index 7c359c8..793fd69 100644 (file)
@@ -26,7 +26,7 @@ BEGIN
     }
   print "# INC = @INC\n";
 
-  plan tests => 3099;
+  plan tests => 3217;
   }
 
 use Math::BigInt lib => 'BareCalc';
index 7e71d7a..c99cc70 100644 (file)
@@ -137,7 +137,16 @@ while (<DATA>)
         $try .= '$x << $y;';
       } elsif ($f eq "fmod") {
         $try .= '$x % $y;';
-      } else { warn "Unknown op '$f'"; }
+       } else {
+       # Functions with three arguments
+       $try .= "\$z = $class->new(\"$args[2]\");";
+
+       if( $f eq "bmodpow") {
+         $try .= "\$x->bmodpow(\$y,\$z);";
+         } elsif ($f eq "bmuladd"){
+          $try .= "\$x->bmuladd(\$y,\$z);";
+         } else { warn "Unknown op '$f'"; }
+       }
     }
     # print "# Trying: '$try'\n";
     $ans1 = eval $try;
@@ -1204,6 +1213,73 @@ baddNaN:+inf:NaN
 -123456789:+987654321:-1111111110
 -123456789:-987654321:864197532
 +123456789:-987654321:1111111110
+&bmuladd
+abc:abc:0:NaN
+abc:+0:0:NaN
++0:abc:0:NaN
++0:0:abc:NaN
+NaNmul:+inf:0:NaN
+NaNmul:-inf:0:NaN
+-inf:NaNmul:0:NaN
++inf:NaNmul:0:NaN
++inf:+inf:0:inf
++inf:-inf:0:-inf
+-inf:+inf:0:-inf
+-inf:-inf:0:inf
++0:+0:0:0
++0:+1:0:0
++1:+0:0:0
++0:-1:0:0
+-1:+0:0:0
+123456789123456789:0:0:0
+0:123456789123456789:0:0
+-1:-1:0:1
+-1:-1:0:1
+-1:+1:0:-1
++1:-1:0:-1
++1:+1:0:1
++2:+3:0:6
+-2:+3:0:-6
++2:-3:0:-6
+-2:-3:0:6
+111:111:0:12321
+10101:10101:0:102030201
+1001001:1001001:0:1002003002001
+100010001:100010001:0:10002000300020001
+10000100001:10000100001:0:100002000030000200001
+11111111111:9:0:99999999999
+22222222222:9:0:199999999998
+33333333333:9:0:299999999997
+44444444444:9:0:399999999996
+55555555555:9:0:499999999995
+66666666666:9:0:599999999994
+77777777777:9:0:699999999993
+88888888888:9:0:799999999992
+99999999999:9:0:899999999991
+11111111111:9:1:100000000000
+22222222222:9:1:199999999999
+33333333333:9:1:299999999998
+44444444444:9:1:399999999997
+55555555555:9:1:499999999996
+66666666666:9:1:599999999995
+77777777777:9:1:699999999994
+88888888888:9:1:799999999993
+99999999999:9:1:899999999992
+-3:-4:-5:7
+3:-4:-5:-17
+-3:4:-5:-17
+3:4:-5:7
+-3:4:5:-7
+3:-4:5:-7
+9999999999999999999:10000000000000000000:1234567890:99999999999999999990000000001234567890
+3.2:5.7:8.9:27.14
+-3.2:5.197:6.05:-10.5804
+&bmodpow
+3:4:8:1
+3:4:7:4
+3:4:7:4
+77777:777:123456789:99995084
+3.2:6.2:5.2:2.970579856718063040273642739529400818
 &fmul
 abc:abc:NaN
 abc:+0:NaN
index 1645663..1b9127e 100755 (executable)
@@ -26,7 +26,7 @@ BEGIN
     }
   print "# INC = @INC\n";
 
-  plan tests => 2070
+  plan tests => 2200
        + 5;            # own tests
   }
 
index b2065c6..dbcb469 100644 (file)
@@ -177,11 +177,13 @@ while (<DATA>)
       }elsif ($f eq "digit"){
         $try .= "\$x->digit(\$y);";
       } else {
+       # Functions with three arguments
        $try .= "\$z = $class->new(\"$args[2]\");";
 
-       # Functions with three arguments
        if( $f eq "bmodpow") {
          $try .= "\$x->bmodpow(\$y,\$z);";
+      } elsif ($f eq "bmuladd"){
+         $try .= "\$x->bmuladd(\$y,\$z);";
        } else { warn "Unknown op '$f'"; }
       }
     } # end else all other ops
@@ -1395,6 +1397,66 @@ abc:+0:NaN
 100000000001:-1:100000000002
 1000000000001:-1:1000000000002
 10000000000001:-1:10000000000002
+&bmuladd
+abc:abc:0:NaN
+abc:+0:0:NaN
++0:abc:0:NaN
++0:0:abc:NaN
+NaNmul:+inf:0:NaN
+NaNmul:-inf:0:NaN
+-inf:NaNmul:0:NaN
++inf:NaNmul:0:NaN
++inf:+inf:0:inf
++inf:-inf:0:-inf
+-inf:+inf:0:-inf
+-inf:-inf:0:inf
++0:+0:0:0
++0:+1:0:0
++1:+0:0:0
++0:-1:0:0
+-1:+0:0:0
+123456789123456789:0:0:0
+0:123456789123456789:0:0
+-1:-1:0:1
+-1:-1:0:1
+-1:+1:0:-1
++1:-1:0:-1
++1:+1:0:1
++2:+3:0:6
+-2:+3:0:-6
++2:-3:0:-6
+-2:-3:0:6
+111:111:0:12321
+10101:10101:0:102030201
+1001001:1001001:0:1002003002001
+100010001:100010001:0:10002000300020001
+10000100001:10000100001:0:100002000030000200001
+11111111111:9:0:99999999999
+22222222222:9:0:199999999998
+33333333333:9:0:299999999997
+44444444444:9:0:399999999996
+55555555555:9:0:499999999995
+66666666666:9:0:599999999994
+77777777777:9:0:699999999993
+88888888888:9:0:799999999992
+99999999999:9:0:899999999991
+11111111111:9:1:100000000000
+22222222222:9:1:199999999999
+33333333333:9:1:299999999998
+44444444444:9:1:399999999997
+55555555555:9:1:499999999996
+66666666666:9:1:599999999995
+77777777777:9:1:699999999994
+88888888888:9:1:799999999993
+99999999999:9:1:899999999992
+-3:-4:-5:7
+3:-4:-5:-17
+-3:4:-5:-17
+3:4:-5:7
+-3:4:5:-7
+3:-4:5:-7
+9999999999999999999:10000000000000000000:1234567890:99999999999999999990000000001234567890
+2:3:12345678901234567890:12345678901234567896
 &bmul
 abc:abc:NaN
 abc:+0:NaN
index f8e2eda..86a41c5 100755 (executable)
@@ -10,7 +10,7 @@ BEGIN
   my $location = $0; $location =~ s/bigintpm.t//;
   unshift @INC, $location; # to locate the testing files
   chdir 't' if -d 't';
-  plan tests => 3099;
+  plan tests => 3217;
   }
 
 use Math::BigInt lib => 'Calc';
index 5f25de8..08b1ae4 100755 (executable)
@@ -26,7 +26,7 @@ BEGIN
     }
   print "# INC = @INC\n"; 
   
-  plan tests => 2070
+  plan tests => 2200
     + 6;       # + our own tests
   }
 
index f35b819..b9c598a 100755 (executable)
@@ -26,7 +26,7 @@ BEGIN
     }
   print "# INC = @INC\n";
 
-  plan tests => 3099
+  plan tests => 3217
     + 5;       # +5 own tests
   }
 
index c8c9fc9..a8d3ec8 100644 (file)
@@ -28,7 +28,7 @@ BEGIN
     }
   print "# INC = @INC\n";
 
-  plan tests => 2070
+  plan tests => 2200
        + 1;
   }