summaryrefslogtreecommitdiff
path: root/demos/perl
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2002-08-05 02:55:27 +0200
committerKevin Ryde <user42@zip.com.au>2002-08-05 02:55:27 +0200
commit6236463cd6586822b5d009cb45d9782634ddf6dc (patch)
tree95eef2fe1ba60fc9b981d4925130ecf95de7cf4a /demos/perl
parentdbb549c1133c31bc1f977a2d35c368d9641455b0 (diff)
downloadgmp-6236463cd6586822b5d009cb45d9782634ddf6dc.tar.gz
* demos/perl/GMP.pm, demos/perl/GMP.xs, demos/perl/GMP/Mpz.pm,
demos/perl/test.pl: Add mpz_import and mpz_export. And lose some prints that were for debugging.
Diffstat (limited to 'demos/perl')
-rw-r--r--demos/perl/test.pl23
1 files changed, 18 insertions, 5 deletions
diff --git a/demos/perl/test.pl b/demos/perl/test.pl
index 9b4cc242d..9f6264b1a 100644
--- a/demos/perl/test.pl
+++ b/demos/perl/test.pl
@@ -433,15 +433,10 @@ ok (bin(3,3) == 1);
my $b = $a;
ok ($b == 3);
clrbit ($a, 0);
- print "a==2\n";
ok ($a == 2);
- print "b==3\n";
ok ($b == 3);
- print "b=a\n";
$b = $a;
- print "b==2\n";
ok ($b == 2);
- print "done\n";
}
{
my $a = 0;
@@ -482,6 +477,15 @@ ok (! even_p(mpz(1)));
ok ( even_p(mpz(2)));
ok (! even_p(mpz(3)));
+{ my $s = mpz_export (1, 2, 1, 0, "0x61626364");
+ ok ($s eq 'abcd'); }
+{ my $s = mpz_export (-1, 2, 1, 0, "0x61626364");
+ ok ($s eq 'cdab'); }
+{ my $s = mpz_export (1, 2, -1, 0, "0x61626364");
+ ok ($s eq 'badc'); }
+{ my $s = mpz_export (-1, 2, -1, 0, "0x61626364");
+ ok ($s eq 'dcba'); }
+
ok (fac(0) == 1);
ok (fac(1) == 1);
ok (fac(2) == 2);
@@ -521,6 +525,15 @@ ok (gcd (-21,-15) == 3);
ok (hamdist(5,7) == 1);
+{ my $z = mpz_import (1, 2, 1, 0, 'abcd');
+ ok ($z == 0x61626364); }
+{ my $z = mpz_import (-1, 2, 1, 0, 'abcd');
+ ok ($z == 0x63646162); }
+{ my $z = mpz_import (1, 2, -1, 0, 'abcd');
+ ok ($z == 0x62616463); }
+{ my $z = mpz_import (-1, 2, -1, 0, 'abcd');
+ ok ($z == 0x64636261); }
+
ok (invert(1,123) == 1);
ok (invert(6,7) == 6);
ok (! defined invert(2,8));