diff options
Diffstat (limited to 'Master/tlpkg/tlperl/lib/bigint.pm')
-rw-r--r-- | Master/tlpkg/tlperl/lib/bigint.pm | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/Master/tlpkg/tlperl/lib/bigint.pm b/Master/tlpkg/tlperl/lib/bigint.pm index 993ea9112f0..3bcf15aa32f 100644 --- a/Master/tlpkg/tlperl/lib/bigint.pm +++ b/Master/tlpkg/tlperl/lib/bigint.pm @@ -1,7 +1,7 @@ package bigint; use 5.006; -$VERSION = '0.36'; +$VERSION = '0.39'; use Exporter; @ISA = qw( Exporter ); @EXPORT_OK = qw( PI e bpi bexp hex oct ); @@ -248,8 +248,7 @@ sub import # see if we can find Math::BigInt::Lite if (!defined $a && !defined $p) # rounding won't work to well { - eval 'require Math::BigInt::Lite;'; - if ($@ eq '') + if (eval { require Math::BigInt::Lite; 1 }) { @import = ( ); # :constant in Lite, not MBI Math::BigInt::Lite->import( ':constant' ); @@ -608,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 |