In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/fa7b7678bab96274911475d96fd3a790506d7f11?hp=9e8951cfb006934b5eb11986ab36e32f5e873db4>
- Log ----------------------------------------------------------------- commit fa7b7678bab96274911475d96fd3a790506d7f11 Author: Tony Cook <[email protected]> Date: Tue Jan 27 15:19:12 2015 +1100 [perl #123064] document limitations of the big* implementation ----------------------------------------------------------------------- Summary of changes: dist/bignum/lib/bigint.pm | 23 ++++++++++++++++++++++- dist/bignum/lib/bignum.pm | 25 ++++++++++++++++++++++++- dist/bignum/lib/bigrat.pm | 25 ++++++++++++++++++++++++- 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/dist/bignum/lib/bigint.pm b/dist/bignum/lib/bigint.pm index 0d7bde9..3bcf15a 100644 --- a/dist/bignum/lib/bigint.pm +++ b/dist/bignum/lib/bigint.pm @@ -1,7 +1,7 @@ package bigint; use 5.006; -$VERSION = '0.37'; +$VERSION = '0.39'; use Exporter; @ISA = qw( Exporter ); @EXPORT_OK = qw( PI e bpi bexp hex oct ); @@ -607,6 +607,27 @@ This method only works on Perl v5.9.4 or later. =over 2 +=item Operator vs literal overloading + +C<bigint> works by overloading handling of integer and floating point +literals, converting them to L<Math::BigInt> objects. + +This means that arithmetic involving only string values or string +literals will be performed using Perl's built-in operators. + +For example: + + use bignum; + my $x = "900000000000000009"; + my $y = "900000000000000007"; + print $x - $y; + +will output C<0> on default 32-bit builds, since C<bigint> never sees +the string literals. To ensure the expression is all treated as +C<Math::BigInt> objects, use a literal number in the expression: + + print +(0+$x) - $y; + =item ranges Perl does not allow overloading of ranges, so you can neither safely use diff --git a/dist/bignum/lib/bignum.pm b/dist/bignum/lib/bignum.pm index 33150a7..67b9ede 100644 --- a/dist/bignum/lib/bignum.pm +++ b/dist/bignum/lib/bignum.pm @@ -1,7 +1,7 @@ package bignum; use 5.006; -$VERSION = '0.38'; +$VERSION = '0.39'; use Exporter; @ISA = qw( bigint ); @EXPORT_OK = qw( PI e bexp bpi hex oct ); @@ -572,6 +572,29 @@ minus infinity. You will get '+inf' when dividing a positive number by 0, and =over 2 +=item Operator vs literal overloading + +C<bignum> works by overloading handling of integer and floating point +literals, converting them to L<Math::BigInt> or L<Math::BigFloat> +objects. + +This means that arithmetic involving only string values or string +literals will be performed using Perl's built-in operators. + +For example: + + use bignum; + my $x = "900000000000000009"; + my $y = "900000000000000007"; + print $x - $y; + +will output C<0> on default 32-bit builds, since C<bigrat> never sees +the string literals. To ensure the expression is all treated as +C<Math::BigInt> or C<BigFloat> objects, use a literal number in the +expression: + + print +(0+$x) - $y; + =item in_effect() This method only works on Perl v5.9.4 or later. diff --git a/dist/bignum/lib/bigrat.pm b/dist/bignum/lib/bigrat.pm index 5845523..b02831b 100644 --- a/dist/bignum/lib/bigrat.pm +++ b/dist/bignum/lib/bigrat.pm @@ -1,7 +1,7 @@ package bigrat; use 5.006; -$VERSION = '0.37'; +$VERSION = '0.39'; require Exporter; @ISA = qw( bigint ); @EXPORT_OK = qw( PI e bpi bexp hex oct ); @@ -477,6 +477,29 @@ This prints out the name and version of all modules used and then exits. =over 2 +=item Operator vs literal overloading + +C<bigrat> works by overloading handling of integer and floating point +literals, converting them to L<Math::BigInt> or L<Math::BigRat> +objects. + +This means that arithmetic involving only string values or string +literals will be performed using Perl's built-in operators. + +For example: + + use bigrat; + my $x = "900000000000000009"; + my $y = "900000000000000007"; + print $x - $y; + +will output C<0> on default 32-bit builds, since C<bigrat> never sees +the string literals. To ensure the expression is all treated as +C<Math::BigInt> or C<Math::BigRat> objects, use a literal number in +the expression: + + print +(0+$x) - $y; + =item in_effect() This method only works on Perl v5.9.4 or later. -- Perl5 Master Repository
