From a7a0833fdec1fda84bec3389ecc9296df0db9440 Mon Sep 17 00:00:00 2001 From: Hugo van der Sanden Date: Sun, 17 Jun 2012 09:32:49 +0100 Subject: [PATCH] Fixup for bigint docs Some copy/paste and insertion errors in bignum 0.19 left the docs in a confusing state. --- dist/bignum/lib/bigint.pm | 76 ++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/dist/bignum/lib/bigint.pm b/dist/bignum/lib/bigint.pm index 926742a..7f877ab 100644 --- a/dist/bignum/lib/bigint.pm +++ b/dist/bignum/lib/bigint.pm @@ -1,7 +1,7 @@ package bigint; use 5.006; -$VERSION = '0.29'; +$VERSION = '0.30'; use Exporter; @ISA = qw( Exporter ); @EXPORT_OK = qw( PI e bpi bexp ); @@ -479,12 +479,46 @@ numbers or as a result of 0/0. '+inf' and '-inf' represent plus respectively minus infinity. You will get '+inf' when dividing a positive number by 0, and '-inf' when dividing any negative number by 0. -=head2 Methods +=head2 Method calls Since all numbers are now objects, you can use all functions that are part of the BigInt API. You can only use the bxxx() notation, and not the fxxx() notation, though. +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 the original and the copy being 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. + +=head2 Methods + =over 2 =item inf() @@ -556,44 +590,6 @@ This method only works on Perl v5.9.4 or later. =back -=head2 MATH LIBRARY - -Math with the numbers is done (by default) by a module called - -=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 the original and the copy being 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. - =head1 CAVEATS =over 2 -- 2.7.4