[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1033739: marked as done (unblock: libmath-bigint-perl/1.999838-1)



Your message dated Sun, 02 Apr 2023 09:18:54 +0000
with message-id <E1pitrS-001cDK-Mk@respighi.debian.org>
and subject line unblock libmath-bigint-perl
has caused the Debian Bug report #1033739,
regarding unblock: libmath-bigint-perl/1.999838-1
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
1033739: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1033739
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

Please unblock package libmath-bigint-perl

In #1012704 and #1017042 (both "serious") there is a problem
mentioned, that ipcalc fails with libmath-bigint-perl 1.999835-1 and
1.999837-1.

This issue was forwarded upstream:
https://rt.cpan.org/Public/Bug/Display.html?id=146411

Upstream just debugged and fixed this issue with a new release
1.999838 with the following upstream changelog:

1.999838 2023-03-30

 * Fix CPAN RT #146411 regarding infinite recursion in bitwise operations. This
   happened when arguments were upgraded and downgraded and upgraded again ad
   infinitum. Add tests to verify the fix.

Upstream also added some test cases (that's why the patch is a little
bit bigger).

[ Reason ]
I solves RC bugs #1012704 and #1017042.

[ Impact ]
ipcalc and other programs may fail with old 1.999837-1.
libconvert-asn1-perl build-depends-indep libmath-bigint-perl, that's
why it is tagged key package.

[ Tests ]
The (updated) testsuite passes with the new package.
The ipcalc failures from the above RC bugs now pass.

[ Risks ]
According to https://udd.debian.org/cgi-bin/key_packages.yaml.cgi it
is a key package.

[ Checklist ]
  [x] all changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in testing

[ Other info ]
I uploaded in behalf of the perl team.


unblock libmath-bigint-perl/1.999838-1

diff --git a/CHANGES b/CHANGES
index 4090295..42b8906 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+1.999838 2023-03-30
+
+ * Fix CPAN RT #146411 regarding infinite recursion in bitwise operations. This
+   happened when arguments were upgraded and downgraded and upgraded again ad
+   infinitum. Add tests to verify the fix.
+
 1.999837 2022-07-02
 
  * Improve the interoperability between objects of different classes for the
diff --git a/META.json b/META.json
index 553efcb..e7516ef 100644
--- a/META.json
+++ b/META.json
@@ -4,7 +4,7 @@
       "Peter John Acklam <pjacklam@gmail.com>"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 7.64, CPAN::Meta::Converter version 2.150010",
+   "generated_by" : "ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010",
    "license" : [
       "perl_5"
    ],
@@ -50,6 +50,6 @@
          "web" : "https://github.com/pjacklam/p5-Math-BigInt";
       }
    },
-   "version" : "1.999837",
-   "x_serialization_backend" : "JSON::PP version 4.09"
+   "version" : "1.999838",
+   "x_serialization_backend" : "JSON::PP version 4.16"
 }
diff --git a/META.yml b/META.yml
index 8f73b8b..c6f3b5e 100644
--- a/META.yml
+++ b/META.yml
@@ -7,7 +7,7 @@ build_requires:
 configure_requires:
   ExtUtils::MakeMaker: '6.58'
 dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 7.64, CPAN::Meta::Converter version 2.150010'
+generated_by: 'ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -24,5 +24,5 @@ requires:
   perl: '5.006001'
 resources:
   repository: https://github.com/pjacklam/p5-Math-BigInt.git
-version: '1.999837'
+version: '1.999838'
 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff --git a/SIGNATURE b/SIGNATURE
index 1dd2231..8cda454 100644
--- a/SIGNATURE
+++ b/SIGNATURE
@@ -15,15 +15,15 @@ not run its Makefile.PL or Build.PL.
 Hash: RIPEMD160
 
 SHA256 961f8c23b6fc94cb9766265257dd548b190087df0c71dfd7d994bc649af5f002 BUGS
-SHA256 ff6e661bb85121620f7afce30a73f12cc1816ab0341b88647a446bafd9c58b38 CHANGES
+SHA256 9b432465325ff89dc74a6149b45f99c76a4184d4cf8220ca67a0eb8205c7d711 CHANGES
 SHA256 7d84c6e69ee6c3ab6301314d2fa4bc233f24bd36a4a546b2cfd05a078bda98b7 CREDITS
 SHA256 fd8f78318c23adef95971cc01ee0e79d68f52f60b761ba28129c8509fff46954 GOALS
 SHA256 28e80ee628ff111dd34a2a26af921693c9c823caadab30c848e4c4f4fc00830f HISTORY
 SHA256 b857edab549ac6893e2df5e1ec768ee46b62bcf1607a55e876f4d23f079eacce LICENSE
 SHA256 eff8d9db8aa0fe02bc74643e8fdea5aaf423cd885e67d1d046526b903d4397b8 MANIFEST
 SHA256 6cbc650165422bed661f292abb91ffaefa416830203a2aa8c790114ce6535cde MANIFEST.SKIP
-SHA256 304e19de0dded923fe216259e271491b1692d2c657266d66d7cced67f515ae30 META.json
-SHA256 f6ce709213efe573904d1586ea91302b4eabd970ef6bb673948bb46db4295571 META.yml
+SHA256 a1dc6acf784a5a6bb73f6b8ac1dfc6fcd83fbb55c9f8f5e0f035b82511d4f42c META.json
+SHA256 035d8a88fbc630bb729ecb63df5c6ca99d9fc3db8ee7b70627070e73e04b690f META.yml
 SHA256 053b2511fa5ac8e6141b5596d6777220ef257a5ddfda3f3ff7325907757660a7 Makefile.PL
 SHA256 99f7f7df45a00c9f19ad38edec8c5dad5f5977c2b1a14ac3bb491ac193db1f7d NEW
 SHA256 2aadb8383836311d8b47a34b7eb1c68043ccd5b90bfc2d9c57016b33579d2385 README
@@ -32,10 +32,10 @@ SHA256 546b67064f9314ed19382b6677bcbe699e774f5edcc31e6dc9567a2e54998eff TODO
 SHA256 77a80748e329a042faaa91eb0b44a493dfdfd726fec854a1a376c8404324b485 examples/1000.txt
 SHA256 702e323f59be58db758a3fa70ffe5fb80d392043bb855b0f172dd748809435df examples/bigprimes.pl
 SHA256 81a3ff3476038ec839c12a2b3548898055112bebc81fbf3513ee5efd6adfd0bd examples/prime.pl
-SHA256 28e278e80e9f8c95f98bcb4d651a6c08bd8396045a8ae8aaba4ce58a9b8d0ae0 lib/Math/BigFloat.pm
-SHA256 33a11cba8142b98f60ad00c38a5f759ef77559b55d875af2dc05a2bdc4c73cd5 lib/Math/BigInt.pm
-SHA256 41959673347331a1a89653a9cd537355c9f0f0e18c69938393c49c47250deec1 lib/Math/BigInt/Calc.pm
-SHA256 f354275521f3a6d3e3359d18ed27278ea4259d45ac604ffd05cd29af033c91fa lib/Math/BigInt/Lib.pm
+SHA256 2d8b8439445754dff1ec3871279b20fb807944d59b13e962e3beb5d99e8077fc lib/Math/BigFloat.pm
+SHA256 eadf4ebf7e263b816676b3b83625b4ac6622cab3e6270cd738e4dee12864f0bc lib/Math/BigInt.pm
+SHA256 0a5031476e2e649e9fb2bbeaf8bb1296bcc1a9f37a8b3389967bca793da76fbb lib/Math/BigInt/Calc.pm
+SHA256 31c7eb01a7517a96acadcffa0001ee0340c492384b390c3c90f9ba1cfd188172 lib/Math/BigInt/Lib.pm
 SHA256 f855e68d0f171debf8369ead8b36d004188f1c9069287a0d3c67a87f9afb1312 t/00sig.t
 SHA256 64c07f96b6a1d6adb075f40bf2dc496fd7951b653458bd9f826e4f76f8e5423d t/01load.t
 SHA256 a756e0bc9a221303e562d0f25969965962e6121605ee9bb0ee3cb54e69dd2222 t/Math/BigFloat/Subclass.pm
@@ -71,7 +71,7 @@ SHA256 0ee0a589b916eba4ba34539dff1825d257d4334017016ed52872d843ce59415e t/mbf_al
 SHA256 bb5c7625cf1ee256e05e9997f1300b6ccddda3b60e60552ecf9aad197cef669f t/mbi_ali.t
 SHA256 c54763f1221b8b5ff3a262b1a7405c686f87197932f11f401fd52f0d4e6d7718 t/mbi_rand.t
 SHA256 38b8514632ee9b9190862914678406bd4861c2b808d2eb4f3333d509066a74a8 t/mbimbf.inc
-SHA256 a0164f4c021c85769b2bc1a871f1ed425ca82b86845380261fe2692822a3e99d t/mbimbf.t
+SHA256 d64300e6afc48bc76b65f25fffdbaea2e5c99ea6019eb93e7696fd1db5f0fb2d t/mbimbf.t
 SHA256 c6631d5efdc13d02d6e90bde8f3705ac1ae3d90bd6a6c337b71bced9e88585cb t/nan_cmp.t
 SHA256 9926011c771c07a60479a1ef9fdb2370670352c3fca14d2a7d71857e4c6b44ad t/new_overloaded.t
 SHA256 53558719e3d79cabe13c718e31262e5b970b02a475f204d0d3209b1cd369eb4d t/req_mbf0.t
@@ -88,8 +88,8 @@ SHA256 e3960b186f58967cd9db62087ed468a3833ea11ea8597fccbef1d70047d18b4d t/sub_mb
 SHA256 a6c9732bef6db595fee11f0a8cd5254681858df9bd2eb796ca6016d8b6fcba72 t/sub_mbi.t
 SHA256 e77752e001d0a5650d815d4221bb1de2d27e821df0a246bec8e6fb21ba261228 t/sub_mif.t
 SHA256 733212fb1e51087fbbd66327659d4b4495f1464b3c19fd5069ab5cfdbcf5cec1 t/trap.t
-SHA256 e096499eafaa38e20c5dce76b8214ae9b7da4a2a9101ad115e836701b1271f11 t/upgrade.inc
-SHA256 ee981278ee767320db4056632aaabae54fc181a58dccdf5923499d90c5b3843c t/upgrade.t
+SHA256 9c4401cb4c608b7edeaf7db4715405faa5f9d970ecf787a4566ca6fba1a39b81 t/upgrade.inc
+SHA256 c6eebb0f9f32a9639e536555aaa51884e3753b622ce594df91a687bc1deaf190 t/upgrade.t
 SHA256 2954aba78a6bd8e66f00f0454b450bdcb128c16033a124046e0215c883a25ab5 t/upgrade2.t
 SHA256 01b543fd9de9aacb54d5d4c64479a064e9c5e3050f9f79b88c0d8d5d2d858f4a t/upgradef.t
 SHA256 abb78d9e1b5f3bbb798f28050130d1fe03bfe61e6a8cb2110ea12795a1d5a850 t/use.t
@@ -320,7 +320,7 @@ SHA256 e26abfaf3833a0b5c8f6b1f4da9f6f5c8aebdef98c6699c9522b66d98ecbf944 xt/autho
 SHA256 aaed59450d1d267018e70889d9b47bed046298b74514d0a837f9c6ab5f429b52 xt/author/objectify-mbf.t
 SHA256 82dcd68d49b9dc8d931c6b1f132431545b3addf7d137074b26e23b0451dec650 xt/author/objectify-mbi.t
 SHA256 291a9d9b311a223e7790640c436f8f5bcc03380b63bb587aad08d8d793905ef8 xt/author/relop-mbi-mbf.t
-SHA256 337d3eafa8653e03f007cc1774ec08b709061c92b4e6b80283e562ad89913a83 xt/author/sparts-mbf.t
+SHA256 5ed9f43664572474dfeb67b4966fb0e10fa237ca36df29ecbf727307a18b3b06 xt/author/sparts-mbf.t
 SHA256 7fb4d9612d591694d3db8ae1cb5549fcec42bbec4a13957bbc2d514388610fe3 xt/author/sparts-mbi.t
 SHA256 697e650c97e0da6e80f3fabc23a1acc47cc647559a8666f8c21094a05dbeb0e6 xt/author/to_base-mbi.t
 SHA256 aca767e64ac49a5f48a93132ae175d3cc451c332232cb3aae157d36784b49ab7 xt/author/to_base_num-mbi.t
@@ -342,11 +342,11 @@ SHA256 d4fa980903622923a45e0c3b2566a8c9425f27648fdd286792f331cb0c99c738 xt/relea
 SHA256 7aa223732dec88d581e015ac171308b256a9d061ea3c832ad4f7048266226e97 xt/release/whitespaces.t
 -----BEGIN PGP SIGNATURE-----
 
-iQEcBAEBAwAGBQJiwHR1AAoJEGcmPl2fr166mH4H/ikWsk/0rAUNMpTaVi56L6/V
-mNraTQrKLhCSKcR0QWrz00zCE/bigNNaA2QAsCOGqRH4kb1KGVufHTqHLTaGa6iM
-IPoG+P6+EJpgD+YLrGfEOZ/4b3T1Ylk6EXqAXZiqhCDXVFgb51NH7hyXZoV54kpQ
-estrTp+EYvKmICBPO9k9zhu5NN/NnRKvDAv+bf3MOpepTrZO/M/gKLNm19TadLgh
-lRFEzpzdff51RfzJP0uFROY9yThO75kLGp9OslskfXtb4gqJ+vN/ZTR8mVdDST5p
-dlXntbESHDLdt6Sl50qHZF7W1VNIq3aOctN+rBwunwweScmPAbpbece7hAO6hkc=
-=NSnp
+iQEcBAEBAwAGBQJkJut0AAoJEGcmPl2fr166mmUH/ArOOsdbdiv0BpsfCNRnujat
+1j3/ZbdPquZeQfrhhTv19S/OnvEJfMNQC23hfONlKYwP++n8uTbaQb6m8++IMEbV
+9C2SUIbqBiNqEI32c8+e0+1u8tfqKmF5DQXrrCzpF3+vsJ7BOGayVNGtW5Bl4wY0
+QZq+U4n4NUlWAqsQYMQGgoYNjo9tdxcS2xAP0JK+JjrUEeySuTNWtNKkuxSak8LR
+CL4lQtGsbOngJ5VaCK5RTEDA+Ly+OO/Y7ulQWenfV13JgoMULXZIehP896fAiydc
+YOi4uxPsamP+TgVU9rXlT4GL56QmVMtjVVTCrKrLIb/55BXymckBGDMByPd2e+k=
+=lbuf
 -----END PGP SIGNATURE-----
diff --git a/debian/changelog b/debian/changelog
index 3e5f970..5130790 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+libmath-bigint-perl (1.999838-1) unstable; urgency=medium
+
+  * New upstream version 1.999838, which fixes infinite recursion in
+    bitwise operations (Closes: #1012704, #1017042).
+  * Update d/upstream/metadata pointing bugs to rt.cpan.org.
+  * Add myself to uploaders.
+  * Add debian/salsa-ci.yml.
+
+ -- Roland Rosenfeld <roland@debian.org>  Fri, 31 Mar 2023 17:13:30 +0200
+
 libmath-bigint-perl (1.999837-1) unstable; urgency=medium
 
   * Import upstream version 1.999837.
diff --git a/debian/control b/debian/control
index 260bf36..caa1d1b 100644
--- a/debian/control
+++ b/debian/control
@@ -1,6 +1,7 @@
 Source: libmath-bigint-perl
 Maintainer: Debian Perl Group <pkg-perl-maintainers@lists.alioth.debian.org>
-Uploaders: gregor herrmann <gregoa@debian.org>
+Uploaders: gregor herrmann <gregoa@debian.org>,
+           Roland Rosenfeld <roland@debian.org>
 Section: perl
 Testsuite: autopkgtest-pkg-perl
 Priority: optional
diff --git a/debian/salsa-ci.yml b/debian/salsa-ci.yml
new file mode 100644
index 0000000..8424db4
--- /dev/null
+++ b/debian/salsa-ci.yml
@@ -0,0 +1,3 @@
+---
+include:
+  - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/recipes/debian.yml
diff --git a/debian/upstream/metadata b/debian/upstream/metadata
index 1550a98..199e14d 100644
--- a/debian/upstream/metadata
+++ b/debian/upstream/metadata
@@ -1,6 +1,7 @@
 ---
 Archive: CPAN
-Bug-Database: https://github.com/pjacklam/p5-Math-BigInt/issues
-Bug-Submit: https://github.com/pjacklam/p5-Math-BigInt/issues/new
+Bug-Database: https://rt.cpan.org/Public/Dist/Display.html?Name=Math-BigInt
+Bug-Submit: mailto:bug-math-bigint@rt.cpan.org
+Changelog: https://metacpan.org/dist/Math-BigInt/changes
 Repository: https://github.com/pjacklam/p5-Math-BigInt.git
 Repository-Browse: https://github.com/pjacklam/p5-Math-BigInt
diff --git a/lib/Math/BigFloat.pm b/lib/Math/BigFloat.pm
index 66300a4..fd08990 100644
--- a/lib/Math/BigFloat.pm
+++ b/lib/Math/BigFloat.pm
@@ -20,7 +20,7 @@ use Carp          qw< carp croak >;
 use Scalar::Util  qw< blessed >;
 use Math::BigInt  qw< >;
 
-our $VERSION = '1.999837';
+our $VERSION = '1.999838';
 $VERSION =~ tr/_//d;
 
 require Exporter;
@@ -2189,16 +2189,16 @@ sub bdiv {
 
     # shortcut to not run through _find_round_parameters again
     if (defined $params[0]) {
-        delete $x->{_a};               # clear before round
+        $x->{_a} = undef;               # clear before round
         $x = $x->bround($params[0], $params[2]); # then round accordingly
     } else {
-        delete $x->{_p};                # clear before round
+        $x->{_p} = undef;               # clear before round
         $x = $x->bfround($params[1], $params[2]); # then round accordingly
     }
     if ($fallback) {
         # clear a/p after round, since user did not request it
-        delete $x->{_a};
-        delete $x->{_p};
+        $x->{_a} = undef;
+        $x->{_p} = undef;
     }
 
     if (wantarray) {
@@ -2208,8 +2208,8 @@ sub bdiv {
         }
         if ($fallback) {
             # clear a/p after round, since user did not request it
-            delete $rem->{_a};
-            delete $rem->{_p};
+            $rem->{_a} = undef;
+            $rem->{_p} = undef;
         }
         $x = $downgrade -> new($x -> bdstr(), @r)
           if defined($downgrade) && $x -> is_int();
@@ -2565,8 +2565,8 @@ sub blog {
     if ($done) {
         if ($fallback) {
             # clear a/p after round, since user did not request it
-            delete $x->{_a};
-            delete $x->{_p};
+            $x->{_a} = undef;
+            $x->{_p} = undef;
         }
         return $downgrade -> new($x -> bdstr(), @r)
           if defined($downgrade) && $x->is_int();
@@ -2584,8 +2584,8 @@ sub blog {
     $$pbr = undef;
     # we also need to disable any set A or P on $x (_find_round_parameters took
     # them already into account), since these would interfere, too
-    delete $x->{_a};
-    delete $x->{_p};
+    $x->{_a} = undef;
+    $x->{_p} = undef;
 
     $done = 0;
 
@@ -2626,8 +2626,8 @@ sub blog {
     }
     if ($fallback) {
         # clear a/p after round, since user did not request it
-        delete $x->{_a};
-        delete $x->{_p};
+        $x->{_a} = undef;
+        $x->{_p} = undef;
     }
     # restore globals
     $$abr = $ab;
@@ -2688,8 +2688,8 @@ sub bexp {
     $$pbr = undef;
     # we also need to disable any set A or P on $x (_find_round_parameters took
     # them already into account), since these would interfere, too
-    delete $x->{_a};
-    delete $x->{_p};
+    $x->{_a} = undef;
+    $x->{_p} = undef;
 
     # Disabling upgrading and downgrading is no longer necessary to avoid an
     # infinite recursion, but it avoids unnecessary upgrading and downgrading in
@@ -2810,8 +2810,8 @@ sub bexp {
         }
     } else {
         # else just round the already computed result
-        delete $x->{_a};
-        delete $x->{_p};
+        $x->{_a} = undef;
+        $x->{_p} = undef;
         # shortcut to not run through _find_round_parameters again
         if (defined $params[0]) {
             $x = $x->bround($params[0], $params[2]); # then round accordingly
@@ -2821,8 +2821,8 @@ sub bexp {
     }
     if ($fallback) {
         # clear a/p after round, since user did not request it
-        delete $x->{_a};
-        delete $x->{_p};
+        $x->{_a} = undef;
+        $x->{_p} = undef;
     }
     # restore globals
     $$abr = $ab;
@@ -2910,8 +2910,8 @@ sub bsin {
     $$pbr = undef;
     # we also need to disable any set A or P on $x (_find_round_parameters took
     # them already into account), since these would interfere, too
-    delete $x->{_a};
-    delete $x->{_p};
+    $x->{_a} = undef;
+    $x->{_p} = undef;
 
     # Disabling upgrading and downgrading is no longer necessary to avoid an
     # infinite recursion, but it avoids unnecessary upgrading and downgrading in
@@ -2926,8 +2926,8 @@ sub bsin {
     my $sign = 1;               # start with -=
     my $below = $class->new(6);
     my $factorial = $class->new(4);
-    delete $x->{_a};
-    delete $x->{_p};
+    $x->{_a} = undef;
+    $x->{_p} = undef;
 
     my $limit = $class->new("1E-". ($scale-1));
     while (1) {
@@ -2959,8 +2959,8 @@ sub bsin {
     }
     if ($fallback) {
         # clear a/p after round, since user did not request it
-        delete $x->{_a};
-        delete $x->{_p};
+        $x->{_a} = undef;
+        $x->{_p} = undef;
     }
     # restore globals
     $$abr = $ab;
@@ -3014,8 +3014,8 @@ sub bcos {
     $$pbr = undef;
     # we also need to disable any set A or P on $x (_find_round_parameters took
     # them already into account), since these would interfere, too
-    delete $x->{_a};
-    delete $x->{_p};
+    $x->{_a} = undef;
+    $x->{_p} = undef;
 
     my $over = $x * $x;         # X ^ 2
     my $x2 = $over->copy();     # X ^ 2; difference between terms
@@ -3023,8 +3023,8 @@ sub bcos {
     my $below = $class->new(2);
     my $factorial = $class->new(3);
     $x = $x->bone();
-    delete $x->{_a};
-    delete $x->{_p};
+    $x->{_a} = undef;
+    $x->{_p} = undef;
 
     my $limit = $class->new("1E-". ($scale-1));
     #my $steps = 0;
@@ -3057,8 +3057,8 @@ sub bcos {
     }
     if ($fallback) {
         # clear a/p after round, since user did not request it
-        delete $x->{_a};
-        delete $x->{_p};
+        $x->{_a} = undef;
+        $x->{_p} = undef;
     }
     # restore globals
     $$abr = $ab;
@@ -3167,8 +3167,8 @@ sub batan {
     $$pbr = undef;
     # We also need to disable any set A or P on $x (_find_round_parameters
     # took them already into account), since these would interfere, too
-    delete $x->{_a};
-    delete $x->{_p};
+    $x->{_a} = undef;
+    $x->{_p} = undef;
 
     # Disabling upgrading and downgrading is no longer necessary to avoid an
     # infinite recursion, but it avoids unnecessary upgrading and downgrading in
@@ -3183,8 +3183,8 @@ sub batan {
     my $sign = 1;               # start with -=
     my $below = $class->new(3);
     my $two = $class->new(2);
-    delete $x->{_a};
-    delete $x->{_p};
+    $x->{_a} = undef;
+    $x->{_p} = undef;
 
     my $limit = $class->new("1E-". ($scale-1));
     #my $steps = 0;
@@ -3225,8 +3225,8 @@ sub batan {
     }
     if ($fallback) {
         # Clear a/p after round, since user did not request it.
-        delete $x->{_a};
-        delete $x->{_p};
+        $x->{_a} = undef;
+        $x->{_p} = undef;
     }
 
     # restore globals
@@ -3322,8 +3322,8 @@ sub batan2 {
     $y = $y -> round(@r);
 
     if ($fallback) {
-        delete $y->{_a};
-        delete $y->{_p};
+        $y->{_a} = undef;
+        $y->{_p} = undef;
     }
 
     return $y;
@@ -3380,8 +3380,8 @@ sub bsqrt {
     $$pbr = undef;
     # we also need to disable any set A or P on $x (_find_round_parameters took
     # them already into account), since these would interfere, too
-    delete $x->{_a};
-    delete $x->{_p};
+    $x->{_a} = undef;
+    $x->{_p} = undef;
 
     # Disabling upgrading and downgrading is no longer necessary to avoid an
     # infinite recursion, but it avoids unnecessary upgrading and downgrading in
@@ -3414,8 +3414,8 @@ sub bsqrt {
         }
         if ($fallback) {
             # clear a/p after round, since user did not request it
-            delete $x->{_a};
-            delete $x->{_p};
+            $x->{_a} = undef;
+            $x->{_p} = undef;
         }
         # re-enable A and P, upgrade is taken care of by "local"
         ${"$class\::accuracy"} = $ab;
@@ -3496,8 +3496,8 @@ sub bsqrt {
     }
     if ($fallback) {
         # clear a/p after round, since user did not request it
-        delete $x->{_a};
-        delete $x->{_p};
+        $x->{_a} = undef;
+        $x->{_p} = undef;
     }
     # restore globals
     $$abr = $ab;
@@ -3567,8 +3567,8 @@ sub broot {
     $$pbr = undef;
     # we also need to disable any set A or P on $x (_find_round_parameters took
     # them already into account), since these would interfere, too
-    delete $x->{_a};
-    delete $x->{_p};
+    $x->{_a} = undef;
+    $x->{_p} = undef;
 
     # Disabling upgrading and downgrading is no longer necessary to avoid an
     # infinite recursion, but it avoids unnecessary upgrading and downgrading in
@@ -3623,8 +3623,8 @@ sub broot {
         }
         if ($done == 0) {
             my $u = $class->bone()->bdiv($y, $scale+4);
-            delete $u->{_a};
-            delete $u->{_p};
+            $u->{_a} = undef;
+            $u->{_p} = undef;
             $x = $x->bpow($u, $scale+4);            # el cheapo
         }
     }
@@ -3638,8 +3638,8 @@ sub broot {
     }
     if ($fallback) {
         # clear a/p after round, since user did not request it
-        delete $x->{_a};
-        delete $x->{_p};
+        $x->{_a} = undef;
+        $x->{_p} = undef;
     }
     # restore globals
     $$abr = $ab;
@@ -3856,16 +3856,18 @@ sub band {
 
     return $x -> bnan(@r) if $x -> is_nan() || $y -> is_nan();
 
-    my $xtmp = Math::BigInt -> new($x -> bint());   # to Math::BigInt
-    $xtmp = $xtmp -> band($y);
+    my $xint = $x -> as_int();          # to Math::BigInt
+    my $yint = $y -> as_int();          # to Math::BigInt
 
-    return $xtmp -> round(@r) if defined $downgrade;
+    $xint = $xint -> band($yint);
 
-    $xtmp = $class -> new($xtmp);                   # back to Math::BigFloat
-    $x -> {sign} = $xtmp -> {sign};
-    $x -> {_m}   = $xtmp -> {_m};
-    $x -> {_es}  = $xtmp -> {_es};
-    $x -> {_e}   = $xtmp -> {_e};
+    return $xint -> round(@r) if defined $downgrade;
+
+    my $xflt = $class -> new($xint);    # back to Math::BigFloat
+    $x -> {sign} = $xflt -> {sign};
+    $x -> {_m}   = $xflt -> {_m};
+    $x -> {_es}  = $xflt -> {_es};
+    $x -> {_e}   = $xflt -> {_e};
 
     return $x -> round(@r);
 }
@@ -3879,16 +3881,18 @@ sub bior {
 
     return $x -> bnan(@r) if $x -> is_nan() || $y -> is_nan();
 
-    my $xtmp = Math::BigInt -> new($x -> bint());   # to Math::BigInt
-    $xtmp = $xtmp -> bior($y);
+    my $xint = $x -> as_int();          # to Math::BigInt
+    my $yint = $y -> as_int();          # to Math::BigInt
+
+    $xint = $xint -> bior($yint);
 
-    return $xtmp -> round(@r) if defined $downgrade;
+    return $xint -> round(@r) if defined $downgrade;
 
-    $xtmp = $class -> new($xtmp);                   # back to Math::BigFloat
-    $x -> {sign} = $xtmp -> {sign};
-    $x -> {_m}   = $xtmp -> {_m};
-    $x -> {_es}  = $xtmp -> {_es};
-    $x -> {_e}   = $xtmp -> {_e};
+    my $xflt = $class -> new($xint);    # back to Math::BigFloat
+    $x -> {sign} = $xflt -> {sign};
+    $x -> {_m}   = $xflt -> {_m};
+    $x -> {_es}  = $xflt -> {_es};
+    $x -> {_e}   = $xflt -> {_e};
 
     return $x -> round(@r);
 }
@@ -3902,16 +3906,18 @@ sub bxor {
 
     return $x -> bnan(@r) if $x -> is_nan() || $y -> is_nan();
 
-    my $xtmp = Math::BigInt -> new($x -> bint());   # to Math::BigInt
-    $xtmp = $xtmp -> bxor($y);
+    my $xint = $x -> as_int();          # to Math::BigInt
+    my $yint = $y -> as_int();          # to Math::BigInt
+
+    $xint = $xint -> bxor($yint);
 
-    return $xtmp -> round(@r) if defined $downgrade;
+    return $xint -> round(@r) if defined $downgrade;
 
-    $xtmp = $class -> new($xtmp);                   # back to Math::BigFloat
-    $x -> {sign} = $xtmp -> {sign};
-    $x -> {_m}   = $xtmp -> {_m};
-    $x -> {_es}  = $xtmp -> {_es};
-    $x -> {_e}   = $xtmp -> {_e};
+    my $xflt = $class -> new($xint);    # back to Math::BigFloat
+    $x -> {sign} = $xflt -> {sign};
+    $x -> {_m}   = $xflt -> {_m};
+    $x -> {_es}  = $xflt -> {_es};
+    $x -> {_e}   = $xflt -> {_e};
 
     return $x -> round(@r);
 }
@@ -3923,16 +3929,16 @@ sub bnot {
 
     return $x -> bnan(@r) if $x -> is_nan();
 
-    my $xtmp = Math::BigInt -> new($x -> bint());   # to Math::BigInt
-    $xtmp = $xtmp -> bnot();
+    my $xint = $x -> as_int();          # to Math::BigInt
+    $xint = $xint -> bnot();
 
-    return $xtmp -> round(@r) if defined $downgrade;
+    return $xint -> round(@r) if defined $downgrade;
 
-    $xtmp = $class -> new($xtmp);                   # back to Math::BigFloat
-    $x -> {sign} = $xtmp -> {sign};
-    $x -> {_m}   = $xtmp -> {_m};
-    $x -> {_es}  = $xtmp -> {_es};
-    $x -> {_e}   = $xtmp -> {_e};
+    my $xflt = $class -> new($xint);    # back to Math::BigFloat
+    $x -> {sign} = $xflt -> {sign};
+    $x -> {_m}   = $xflt -> {_m};
+    $x -> {_es}  = $xflt -> {_es};
+    $x -> {_e}   = $xflt -> {_e};
 
     return $x -> round(@r);
 }
@@ -3995,7 +4001,7 @@ sub bround {
     $m = $m->bround($scale, $mode);     # round mantissa
     $x->{_m} = $m->{value};             # get our mantissa back
     $x->{_a} = $scale;                  # remember rounding
-    delete $x->{_p};                    # and clear P
+    $x->{_p} = undef;                   # and clear P
 
     # bnorm() downgrades if necessary, so no need to check whether to downgrade.
     $x->bnorm();                # del trailing zeros gen. by bround()
@@ -4040,7 +4046,7 @@ sub bfround {
     }
 
     $x->{_p} = $scale;          # remember round in any case
-    delete $x->{_a};            # and clear A
+    $x->{_a} = undef;           # and clear A
     if ($scale < 0) {
         # round right from the '.'
 
@@ -4394,17 +4400,13 @@ sub sparts {
 
     # Finite number.
 
-    my $mant = $x -> copy();
+    my $mant = $class -> new($x);
     $mant->{_es} = '+';
     $mant->{_e}  = $LIB->_zero();
     $mant = $downgrade -> new($mant) if defined $downgrade;
     return $mant unless wantarray;
 
-    my $expo = bless { sign => $x -> {_es},
-                       _m   => $LIB->_copy($x -> {_e}),
-                       _es  => '+',
-                       _e   => $LIB->_zero(),
-                     }, $class;
+    my $expo = $class -> new($x -> {_es} . $LIB->_str($x -> {_e}));
     $expo = $downgrade -> new($expo) if defined $downgrade;
     return ($mant, $expo);
 }
@@ -5520,8 +5522,8 @@ sub _log {
 
         last if $next->bacmp($limit) <= 0;
 
-        delete $next->{_a};
-        delete $next->{_p};
+        $next->{_a} = undef;
+        $next->{_p} = undef;
         $x = $x->badd($next);
         # calculate things for the next term
         $over *= $u;
@@ -5792,8 +5794,8 @@ sub _pow {
     $$pbr = undef;
     # we also need to disable any set A or P on $x (_find_round_parameters took
     # them already into account), since these would interfere, too
-    delete $x->{_a};
-    delete $x->{_p};
+    $x->{_a} = undef;
+    $x->{_p} = undef;
 
     # Disabling upgrading and downgrading is no longer necessary to avoid an
     # infinite recursion, but it avoids unnecessary upgrading and downgrading in
@@ -5843,8 +5845,8 @@ sub _pow {
     }
     if ($fallback) {
         # clear a/p after round, since user did not request it
-        delete $x->{_a};
-        delete $x->{_p};
+        $x->{_a} = undef;
+        $x->{_p} = undef;
     }
     # restore globals
     $$abr = $ab;
diff --git a/lib/Math/BigInt.pm b/lib/Math/BigInt.pm
index 65e1446..c2dfe7c 100644
--- a/lib/Math/BigInt.pm
+++ b/lib/Math/BigInt.pm
@@ -23,7 +23,7 @@ use warnings;
 use Carp          qw< carp croak >;
 use Scalar::Util  qw< blessed refaddr >;
 
-our $VERSION = '1.999837';
+our $VERSION = '1.999838';
 $VERSION =~ tr/_//d;
 
 require Exporter;
@@ -350,34 +350,34 @@ sub accuracy {
     if (@_ > 0) {
         my $a = shift;
         if (defined $a) {
-            $a = $a->numify() if ref($a) && $a->can('numify');
+            $a = $a -> can('numify') ? $a -> numify() : 0 + "$a" if ref($a);
             # also croak on non-numerical
-            if (!$a || $a <= 0) {
-                croak('Argument to accuracy must be greater than zero');
-            }
-            if (int($a) != $a) {
-                croak('Argument to accuracy must be an integer');
-            }
+            croak "accuracy must be a number, not '$a'"
+              unless $a =~/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?\z/;
+            croak "accuracy must be an integer, not '$a'"
+              if $a != int $a;
+            croak "accuracy must be greater than zero, not '$a'"
+              if $a <= 0;
         }
 
         if (ref($x)) {
             # Set instance variable.
-            $x = $x->bround($a) if $a; # not for undef, 0
-            $x->{_a} = $a;        # set/overwrite, even if not rounded
-            delete $x->{_p};      # clear P
+            $x = $x->bround($a) if defined $a;
+            $x->{_a} = $a;      # set/overwrite, even if not rounded
+            $x->{_p} = undef;   # clear P
             # Why return class variable here? Fixme!
             $a = ${"${class}::accuracy"} unless defined $a;
         } else {
             # Set class variable.
-            ${"${class}::accuracy"} = $a; # set global A
-            ${"${class}::precision"} = undef; # clear global P
+            ${"${class}::accuracy"}  = $a;      # set global A
+            ${"${class}::precision"} = undef;   # clear global P
         }
 
         return $a;              # shortcut
     }
 
     # Return instance variable.
-    return $x->{_a} if ref($x) && (defined($x->{_a}) || defined($x->{_p}));
+    return $x->{_a} if ref($x);
 
     # Return class variable.
     return ${"${class}::accuracy"};
@@ -396,30 +396,31 @@ sub precision {
     if (@_ > 0) {
         my $p = shift;
         if (defined $p) {
-            $p = $p->numify() if ref($p) && $p->can('numify');
-            if ($p != int $p) {
-                croak('Argument to precision must be an integer');
-            }
+            $p = $p -> can('numify') ? $p -> numify() : 0 + "$p" if ref($p);
+            croak "precision must be a number, not '$p'"
+              unless $p =~/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?\z/;
+            croak "precision must be an integer, not '$p'"
+              if $p != int $p;
         }
 
         if (ref($x)) {
             # Set instance variable.
-            $x = $x->bfround($p) if $p; # not for undef, 0
-            $x->{_p} = $p;         # set/overwrite, even if not rounded
-            delete $x->{_a};       # clear A
+            $x = $x->bfround($p) if defined $p;
+            $x->{_p} = $p;      # set/overwrite, even if not rounded
+            $x->{_a} = undef;   # clear A
             # Why return class variable here? Fixme!
             $p = ${"${class}::precision"} unless defined $p;
         } else {
             # Set class variable.
-            ${"${class}::precision"} = $p; # set global P
-            ${"${class}::accuracy"} = undef; # clear global A
+            ${"${class}::precision"} = $p;      # set global P
+            ${"${class}::accuracy"}  = undef;   # clear global A
         }
 
         return $p;              # shortcut
     }
 
     # Return instance variable.
-    return $x->{_p} if ref($x) && (defined($x->{_a}) || defined($x->{_p}));
+    return $x->{_p} if ref($x);
 
     # Return class variable.
     return ${"${class}::precision"};
@@ -3770,7 +3771,7 @@ sub bfround {
     # no-op for Math::BigInt objects if $n <= 0
     $x = $x->bround($x->length()-$scale, $mode) if $scale > 0;
 
-    delete $x->{_a};            # delete to save memory
+    $x->{_a} = undef;
     $x->{_p} = $scale;          # store new _p
     $x;
 }
@@ -4003,8 +4004,8 @@ sub mantissa {
         return $class->new($x->{sign}, @r);
     }
     my $m = $x->copy();
-    delete $m->{_p};
-    delete $m->{_a};
+    $m -> precision(undef);
+    $m -> accuracy(undef);
 
     # that's a bit inefficient:
     my $zeros = $LIB->_zeros($m->{value});
diff --git a/lib/Math/BigInt/Calc.pm b/lib/Math/BigInt/Calc.pm
index a5429dc..6876e25 100644
--- a/lib/Math/BigInt/Calc.pm
+++ b/lib/Math/BigInt/Calc.pm
@@ -7,7 +7,7 @@ use warnings;
 use Carp qw< carp croak >;
 use Math::BigInt::Lib;
 
-our $VERSION = '1.999837';
+our $VERSION = '1.999838';
 $VERSION =~ tr/_//d;
 
 our @ISA = ('Math::BigInt::Lib');
diff --git a/lib/Math/BigInt/Lib.pm b/lib/Math/BigInt/Lib.pm
index 37fa9b9..14e6bf2 100644
--- a/lib/Math/BigInt/Lib.pm
+++ b/lib/Math/BigInt/Lib.pm
@@ -4,7 +4,7 @@ use 5.006001;
 use strict;
 use warnings;
 
-our $VERSION = '1.999837';
+our $VERSION = '1.999838';
 $VERSION =~ tr/_//d;
 
 use Carp;
diff --git a/t/mbimbf.t b/t/mbimbf.t
index 23599dd..064ca36 100644
--- a/t/mbimbf.t
+++ b/t/mbimbf.t
@@ -7,7 +7,7 @@ use strict;
 use warnings;
 
 use Test::More tests => 712             # tests in require'd file
-                        + 26;           # tests in this file
+                        + 52;           # tests in this file
 
 use Math::BigInt only => 'Calc';
 use Math::BigFloat;
@@ -58,24 +58,71 @@ foreach my $class (qw/Math::BigInt Math::BigFloat/) {
 }
 
 foreach my $class (qw/Math::BigInt Math::BigFloat/)  {
-    $class->accuracy(42);
+    my $x;
 
-    # $x gets A of 42, too!
-    my $x = $class->new(123);
+    # Accuracy
 
-    # really?
-    is($x->accuracy(), 42, '$x has A of 42');
+    # set and check the class accuracy
+    $class->accuracy(1);
+    is($class->accuracy(), 1, "$class has A of 1");
 
-    # $x has no A, but the global is still in effect for $x so the return value
-    # of that operation should be 42, not undef
-    is($x->accuracy(undef), 42, '$x has A from global');
+    # a new instance gets the class accuracy
+    $x = $class->new(123);
+    is($x->accuracy(), 1, '$x has A of 1');
 
-    # so $x should still have A = 42
-    is($x->accuracy(), 42, '$x has still A of 42');
+    # set and check the instance accuracy
+    $x->accuracy(2);
+    is($x->accuracy(), 2, '$x has A of 2');
 
-    # reset for further tests
+    # change the class accuracy
+    $class->accuracy(3);
+    is($class->accuracy(), 3, "$class has A of 3");
+
+    # verify that the instance accuracy hasn't changed
+    is($x->accuracy(), 2, '$x still has A of 2');
+
+    # change the instance accuracy
+    $x->accuracy(undef);
+    is($x->accuracy(), undef, '$x now has A of undef');
+
+    # check the class accuracy
+    is($class->accuracy(), 3, "$class still has A of 3");
+
+    # change the class accuracy again
     $class->accuracy(undef);
+    is($class->accuracy(), undef, "$class now has A of undef");
+
+    # Precision
+
+    # set and check the class precision
+    $class->precision(1);
+    is($class->precision(), 1, "$class has A of 1");
+
+    # a new instance gets the class precision
+    $x = $class->new(123);
+    is($x->precision(), 1, '$x has A of 1');
+
+    # set and check the instance precision
+    $x->precision(2);
+    is($x->precision(), 2, '$x has A of 2');
+
+    # change the class precision
+    $class->precision(3);
+    is($class->precision(), 3, "$class has A of 3");
+
+    # verify that the instance precision hasn't changed
+    is($x->precision(), 2, '$x still has A of 2');
+
+    # change the instance precision
+    $x->precision(undef);
+    is($x->precision(), undef, '$x now has A of undef');
+
+    # check the class precision
+    is($class->precision(), 3, "$class still has A of 3");
+
+    # change the class precision again
     $class->precision(undef);
+    is($class->precision(), undef, "$class now has A of undef");
 }
 
 # bug with blog(Math::BigFloat, Math::BigInt)
diff --git a/t/upgrade.inc b/t/upgrade.inc
index d8bd119..dcd2ad6 100644
--- a/t/upgrade.inc
+++ b/t/upgrade.inc
@@ -1108,6 +1108,8 @@ abc:0:NaN
 -7:-4:-8
 -7:4:0
 -4:7:4
+1:0.5:0
+
 # equal arguments are treated special, so also do some test with unequal ones
 0xFFFF:0xFFFF:0x0xFFFF
 0xFFFFFF:0xFFFFFF:0x0xFFFFFF
@@ -1140,6 +1142,8 @@ abc:0:NaN
 -6:-6:-6
 -7:4:-3
 -4:7:-1
+1:0.5:1
+
 # equal arguments are treated special, so also do some test with unequal ones
 0xFFFF:0xFFFF:0x0xFFFF
 0xFFFFFF:0xFFFFFF:0x0xFFFFFF
@@ -1189,6 +1193,8 @@ abc:0:NaN
 -4:7:-5
 4:-7:-3
 -4:-7:5
+1:0.5:1
+
 # equal arguments are treated special, so also do some test with unequal ones
 0xFFFF:0xFFFF:0
 0xFFFFFF:0xFFFFFF:0
diff --git a/t/upgrade.t b/t/upgrade.t
index 132c9c5..43e562f 100644
--- a/t/upgrade.t
+++ b/t/upgrade.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 2134            # tests in require'd file
+use Test::More tests => 2140            # tests in require'd file
                          + 6;           # tests in this file
 
 use Math::BigInt;
diff --git a/xt/author/sparts-mbf.t b/xt/author/sparts-mbf.t
index f67ec95..45c0d64 100644
--- a/xt/author/sparts-mbf.t
+++ b/xt/author/sparts-mbf.t
@@ -57,7 +57,7 @@ note(qq|\nVerify that accuracy depends on invocand, not class.\n\n|);
     my ($mant, $expo) = $x -> sparts();
     cmp_ok($mant, '==', 3, "value of significand");
     cmp_ok($expo, '==', 0, "value of exponent");
-    cmp_ok($mant -> accuracy(), '==', 10, "accuracy of significand");
+    cmp_ok($mant -> accuracy(), '==', 20, "accuracy of significand");
     cmp_ok($expo -> accuracy(), '==', 20, "accuracy of exponent");
 }
 
@@ -71,7 +71,7 @@ note(qq|\nVerify that precision depends on invocand, not class.\n\n|);
     my ($mant, $expo) = $x -> sparts();
     cmp_ok($mant, '==', 3, "value of significand");
     cmp_ok($expo, '==', 0, "value of exponent");
-    cmp_ok($mant -> precision(), '==', 10, "precision of significand");
+    cmp_ok($mant -> precision(), '==', 20, "precision of significand");
     cmp_ok($expo -> precision(), '==', 20, "precision of exponent");
 }
 

Attachment: signature.asc
Description: PGP signature


--- End Message ---
--- Begin Message ---
Unblocked.

--- End Message ---

Reply to: