Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

whoops. actually fix this test

  • Loading branch information...
commit 74b9c03fab26e0972df3533836ac6c5faec928f9 1 parent 00aac4b
Bob Kuo bubaflub authored
Showing with 15 additions and 9 deletions.
  1. +2 −2 lib/Math/Primality.pm
  2. +13 −7 t/aks.t
4 lib/Math/Primality.pm
View
@@ -724,9 +724,9 @@ sub _Rmpz_logbase2fl($) {
my $n = $_[0];
my ($double, $si) = Rmpz_get_d_2exp($n); # $double * 2^$si ~= $op (with 0.5 <= abs($double) < 1)
if ($double == 0.5) {
- $si--;
- } else {
$si++;
+ } else {
+ $si--;
}
return $si;
}
20 t/aks.t
View
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More tests => 14;
use Math::Primality;
use Math::GMPz;
@@ -19,10 +19,16 @@ sub log2 {
return log($n)/log(2);
}
### check _Rmpz_logbase2cl ###
-$a = ceil(log2(100));
-$b = Math::Primality::_Rmpz_logbase2cl(Math::GMPz->new(100));
-is("$a", "$b", "log2(100) == _Rmpz_logbase2cl(100)");
+for (my $i = 1; $i < 7; $i++) {
+ my $n = $i * 100;
+ my $a = ceil(log2($n));
+ my $b = Math::Primality::_Rmpz_logbase2cl(Math::GMPz->new($n));
+ is("$a", "$b", "log2($n) == _Rmpz_logbase2cl($n)");
+}
### check _Rmpz_logbase2fl ###
-$a = floor(log2(100));
-$b = Math::Primality::_Rmpz_logbase2cl(Math::GMPz->new(100));
-is("$a", "$b", "log2(100) == _Rmpz_logbase2cl(100)");
+for (my $i = 1; $i < 7; $i++) {
+ my $n = $i * 100;
+ $a = floor(log2($n));
+ $b = Math::Primality::_Rmpz_logbase2fl(Math::GMPz->new($n));
+ is("$a", "$b", "log2($n) == _Rmpz_logbase2fl($n)");
+}
Please sign in to comment.
Something went wrong with that request. Please try again.