summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/bignum.pm
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-04-05 22:27:26 +0000
committerKarl Berry <karl@freefriends.org>2016-04-05 22:27:26 +0000
commitb56b320b5e2515160073fa1b469514002688fe11 (patch)
tree965a7100c5e45fca8ec803d22b8b6ce14fca4633 /Master/tlpkg/tlperl/lib/bignum.pm
parentd26c206452d2e285c3bbf949f34011e4a55fd8f9 (diff)
tlperl 5.22.1 from siep
git-svn-id: svn://tug.org/texlive/trunk@40252 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/bignum.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/bignum.pm28
1 files changed, 25 insertions, 3 deletions
diff --git a/Master/tlpkg/tlperl/lib/bignum.pm b/Master/tlpkg/tlperl/lib/bignum.pm
index 40aedceca71..67b9ede8351 100644
--- a/Master/tlpkg/tlperl/lib/bignum.pm
+++ b/Master/tlpkg/tlperl/lib/bignum.pm
@@ -1,7 +1,7 @@
package bignum;
use 5.006;
-$VERSION = '0.37';
+$VERSION = '0.39';
use Exporter;
@ISA = qw( bigint );
@EXPORT_OK = qw( PI e bexp bpi hex oct );
@@ -155,8 +155,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' );
@@ -573,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.