Too many my $fh:s.
[p5sagit/p5-mst-13.2.git] / lib / bignum.pm
index fb7db9f..056b45f 100644 (file)
@@ -1,7 +1,7 @@
 package bignum;
 require 5.005;
 
-$VERSION = '0.13';
+$VERSION = '0.14';
 use Exporter;
 @EXPORT_OK     = qw( ); 
 @EXPORT        = qw( inf NaN ); 
@@ -33,7 +33,7 @@ sub AUTOLOAD
         if (defined $_[0])
           {
           Math::BigInt->$name($_[0]);
-          Math::BigFloat->$name($_[0]);
+          return Math::BigFloat->$name($_[0]);
           }
         return Math::BigInt->$name();
         };
@@ -344,6 +344,40 @@ the BigInt or BigFloat API. It is wise to use only the bxxx() notation, and not
 the fxxx() notation, though. This makes it possible that the underlying object
 might morph into a different class than BigFloat.
 
+=head2 CAVEAT
+
+But a warning is in order. When using the following to make a copy of a number,
+only a shallow copy will be made.
+
+        $x = 9; $y = $x;
+        $x = $y = 7;
+
+Using the copy or the original with overloaded math is okay, e.g. the
+following work:
+
+        $x = 9; $y = $x;
+        print $x + 1, " ", $y,"\n";     # prints 10 9
+
+but calling any method that modifies the number directly will result in
+B<both> the original and the copy beeing destroyed:
+
+        $x = 9; $y = $x;
+        print $x->badd(1), " ", $y,"\n";        # prints 10 10
+
+        $x = 9; $y = $x;
+        print $x->binc(1), " ", $y,"\n";        # prints 10 10
+
+        $x = 9; $y = $x;
+        print $x->bmul(2), " ", $y,"\n";        # prints 18 18
+
+Using methods that do not modify, but testthe contents works:
+
+        $x = 9; $y = $x;
+        $z = 9 if $x->is_zero();                # works fine
+
+See the documentation about the copy constructor and C<=> in overload, as
+well as the documentation in BigInt for further details.
+
 =over 2
 
 =item inf()