lib/Math/BigInt/t/bare_mbf.t Test MBF under Math::BigInt::BareCalc
lib/Math/BigInt/t/bare_mbi.t Test MBI under Math::BigInt::BareCalc
lib/Math/BigInt/t/bare_mif.t Rounding tests under BareCalc
+lib/Math/BigInt/t/big_pi_e.t test bpi() and bexp()
lib/Math/BigInt/t/bigfltpm.inc Shared tests for bigfltpm.t and sub_mbf.t
lib/Math/BigInt/t/bigfltpm.t See if BigFloat.pm works
lib/Math/BigInt/t/bigintc.t See if BigInt/Calc.pm works
$n = undef if $n eq 'Math::BigFloat';
}
$self = ref($self) if ref($self);
+ my $fallback = defined $n ? 0 : 1;
$n = 40 if !defined $n || $n < 1;
# after 黃見利 (Hwang Chien-Lih) (1997)
$v->bdiv($v_d, $n);
$w->bdiv($w_d, $n);
- delete $x->{a}; delete $y->{a}; delete $z->{a};
- delete $u->{a}; delete $v->{a}; delete $w->{a};
+ delete $x->{_a}; delete $y->{_a}; delete $z->{_a};
+ delete $u->{_a}; delete $v->{_a}; delete $w->{_a};
$x->badd($y)->bsub($z)->badd($u)->bsub($v)->bsub($w);
- $x->round($n-4);
+ $x->bround($n-4);
+ delete $x->{_a} if $fallback == 1;
+ $x;
}
sub bcos
my $x2 = $over->copy(); # X ^ 2; difference between terms
my $sign = 1; # start with -=
my $below = $self->new(2); my $factorial = $self->new(3);
- $x->bone(); delete $x->{a}; delete $x->{p};
+ $x->bone(); delete $x->{_a}; delete $x->{_p};
my $limit = $self->new("1E-". ($scale-1));
#my $steps = 0;
$over->bmul($x); # X ^ 3 as starting value
my $sign = 1; # start with -=
my $below = $self->new(6); my $factorial = $self->new(4);
- delete $x->{a}; delete $x->{p};
+ delete $x->{_a}; delete $x->{_p};
my $limit = $self->new("1E-". ($scale-1));
#my $steps = 0;
my $sign = 1; # start with -=
my $below = $self->new(3);
my $two = $self->new(2);
- delete $x->{a}; delete $x->{p};
+ delete $x->{_a}; delete $x->{_p};
my $limit = $self->new("1E-". ($scale-1));
#my $steps = 0;
--- /dev/null
+#!/usr/bin/perl -w
+
+# Test bpi() and bexp()
+
+use Test::More;
+use strict;
+
+BEGIN
+ {
+ $| = 1;
+ # to locate the testing files
+ my $location = $0; $location =~ s/big_pi_e.t//i;
+ if ($ENV{PERL_CORE})
+ {
+ # testing with the core distribution
+ @INC = qw(../lib);
+ }
+ unshift @INC, '../lib';
+ if (-d 't')
+ {
+ chdir 't';
+ require File::Spec;
+ unshift @INC, File::Spec->catdir(File::Spec->updir, $location);
+ }
+ else
+ {
+ unshift @INC, $location;
+ }
+ print "# INC = @INC\n";
+
+ plan tests => 8;
+ }
+
+use Math::BigFloat;
+
+#############################################################################
+
+my $pi = Math::BigFloat::bpi();
+
+ok (!exists $pi->{_a}, 'A not set');
+ok (!exists $pi->{_p}, 'P not set');
+
+$pi = Math::BigFloat->bpi();
+
+ok (!exists $pi->{_a}, 'A not set');
+ok (!exists $pi->{_p}, 'P not set');
+
+$pi = Math::BigFloat->bpi(10);
+
+is ($pi->{_a}, 10, 'A set');
+is ($pi->{_p}, undef, 'P not set');
+
+#############################################################################
+my $e = Math::BigFloat->new(1)->bexp();
+
+ok (!exists $e->{_a}, 'A not set');
+ok (!exists $e->{_p}, 'P not set');
+
+