On Thu Dec 31 09:23:17 2015, hv@crypt.org wrote:
Show quoted text> On Wed Jul 29 07:28:33 2015, SHLOMIF wrote:
> > can you provide a testcase and/or a patch for all that?
>
> Here's a testcase that exercises it using int(), when running on a 64-
> bit perl-5.18.4 with Math-GMP-2.11:
> % perl -MMath::GMP -wle '$a = 12874555777890293787; $b = Math::GMP-
> >new($a); $c = int($a); $d = int($b); print for ($a, $b, $c, $d)'
> 12874555777890293787
> 12874555777890293787
> 12874555777890293787
> 3651183741035517979
> %
Oh sorry, this must go through a different pathway since it isn't fixed by the removing the 0+ overload; the case I reported earlier against Math::Prime::Util (
https://rt.cpan.org/Public/Bug/Display.html?id=110813) is fixed by the patch below though.
Before:
% /path/to/perl testprog
source 12874555777890293787 (3 ^ 1 . 4243 ^ 2 . 488239 ^ 2)
dest 3651183741035517979 (19 ^ 4 . 28016848712299 ^ 1)
source hex b2ab9c44861a981b
dest hex 32ab9c44861a981b
%
After:
% /path/to/perl testprog
source 12874555777890293787 (3 ^ 1 . 4243 ^ 2 . 488239 ^ 2)
dest 12874555777890293787 (3 ^ 1 . 4243 ^ 2 . 488239 ^ 2)
source hex b2ab9c44861a981b
dest hex b2ab9c44861a981b
%
The difference between them:
--- ./lib/Math/GMP.pm.old 2015-08-16 19:12:39.000000000 +0100
+++ ./lib/Math/GMP.pm 2015-12-31 14:30:29.607982997 +0000
@@ -34,7 +34,8 @@
use overload (
'""' => sub { stringify($_[0]) },
- '0+' => sub { intify($_[0]) },
+# don't do this: it isn't needed, and truncates large UV to IV
+# '0+' => sub { intify($_[0]) },
'bool' => sub { $_[0] != 0 },
'<=>' => \&op_spaceship,
Hugo