diff options
author | 2013-03-25 20:40:40 +0000 | |
---|---|---|
committer | 2013-03-25 20:40:40 +0000 | |
commit | 48950c12d106c85f315112191a0228d7b83b9510 (patch) | |
tree | 54e43d54484c1bfe9bb06a10ede0ba3e2fa52c08 /gnu/usr.bin/perl/cpan/Math-BigRat/t/Math/BigRat/Test.pm | |
parent | avoid null dereference affecting mod_perl, Perl RT bug 116441 (diff) | |
download | wireguard-openbsd-48950c12d106c85f315112191a0228d7b83b9510.tar.xz wireguard-openbsd-48950c12d106c85f315112191a0228d7b83b9510.zip |
merge/resolve conflicts
(some more to do after this one)
Diffstat (limited to 'gnu/usr.bin/perl/cpan/Math-BigRat/t/Math/BigRat/Test.pm')
-rw-r--r-- | gnu/usr.bin/perl/cpan/Math-BigRat/t/Math/BigRat/Test.pm | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/gnu/usr.bin/perl/cpan/Math-BigRat/t/Math/BigRat/Test.pm b/gnu/usr.bin/perl/cpan/Math-BigRat/t/Math/BigRat/Test.pm deleted file mode 100644 index 630a84359a4..00000000000 --- a/gnu/usr.bin/perl/cpan/Math-BigRat/t/Math/BigRat/Test.pm +++ /dev/null @@ -1,122 +0,0 @@ -package Math::BigRat::Test; - -require 5.005_02; -use strict; - -use Exporter; -use Math::BigRat; -use Math::BigFloat; -use vars qw($VERSION @ISA - $accuracy $precision $round_mode $div_scale); - -@ISA = qw(Math::BigRat Exporter); -$VERSION = 0.04; - -use overload; # inherit overload from BigRat - -# Globals -$accuracy = $precision = undef; -$round_mode = 'even'; -$div_scale = 40; - -my $class = 'Math::BigRat::Test'; - -#ub new -#{ -# my $proto = shift; -# my $class = ref($proto) || $proto; -# -# my $value = shift; -# my $a = $accuracy; $a = $_[0] if defined $_[0]; -# my $p = $precision; $p = $_[1] if defined $_[1]; -# # Store the floating point value -# my $self = Math::BigFloat->new($value,$a,$p,$round_mode); -# bless $self, $class; -# $self->{'_custom'} = 1; # make sure this never goes away -# return $self; -#} - -BEGIN - { - *fstr = \&bstr; - *fsstr = \&bsstr; - *objectify = \&Math::BigInt::objectify; - *AUTOLOAD = \&Math::BigRat::AUTOLOAD; - no strict 'refs'; - foreach my $method ( qw/ div acmp floor ceil root sqrt log fac modpow modinv/) - { - *{'b' . $method} = \&{'Math::BigRat::b' . $method}; - } - } - -sub fround - { - my ($x,$a) = @_; - - #print "$a $accuracy $precision $round_mode\n"; - Math::BigFloat->round_mode($round_mode); - Math::BigFloat->accuracy($a || $accuracy); - Math::BigFloat->precision(undef); - my $y = Math::BigFloat->new($x->bsstr(),undef,undef); - $class->new($y->fround($a)); - } - -sub ffround - { - my ($x,$p) = @_; - - Math::BigFloat->round_mode($round_mode); - Math::BigFloat->accuracy(undef); - Math::BigFloat->precision($p || $precision); - my $y = Math::BigFloat->new($x->bsstr(),undef,undef); - $class->new($y->ffround($p)); - } - -sub bstr - { - # calculate a BigFloat compatible string output - my ($x) = @_; - - $x = $class->new($x) unless ref $x; - - if ($x->{sign} !~ /^[+-]$/) # inf, NaN etc - { - my $s = $x->{sign}; $s =~ s/^\+//; # +inf => inf - return $s; - } - - my $s = ''; $s = $x->{sign} if $x->{sign} ne '+'; # +3 vs 3 - -# print " bstr \$x ", $accuracy || $x->{_a} || 'notset', " ", $precision || $x->{_p} || 'notset', "\n"; - return $s.$x->{_n} if $x->{_d}->is_one(); - my $output = Math::BigFloat->new($x->{_n})->bdiv($x->{_d}); - local $Math::BigFloat::accuracy = $accuracy || $x->{_a}; - local $Math::BigFloat::precision = $precision || $x->{_p}; - $s.$output->bstr(); - } - -sub numify - { - $_[0]->bsstr(); - } - -sub bsstr - { - # calculate a BigFloat compatible string output - my ($x) = @_; - - $x = $class->new($x) unless ref $x; - - if ($x->{sign} !~ /^[+-]$/) # inf, NaN etc - { - my $s = $x->{sign}; $s =~ s/^\+//; # +inf => inf - return $s; - } - - my $s = ''; $s = $x->{sign} if $x->{sign} ne '+'; # +3 vs 3 - - my $output = Math::BigFloat->new($x->{_n})->bdiv($x->{_d}); - return $s.$output->bsstr(); - } - -1; |