Math-BigInt v1.49 released
[p5sagit/p5-mst-13.2.git] / t / lib / Math / BigInt / Subclass.pm
1 #!/usr/bin/perl -w
2
3 package Math::BigInt::Subclass;
4
5 require 5.005_02;
6 use strict;
7
8 use Exporter;
9 use Math::BigInt(1.49);
10 use vars qw($VERSION @ISA $PACKAGE @EXPORT_OK
11             $accuracy $precision $round_mode $div_scale);
12
13 @ISA = qw(Exporter Math::BigInt);
14 @EXPORT_OK = qw(bgcd);
15
16 $VERSION = 0.02;
17
18 # Globals
19 $accuracy = $precision = undef;
20 $round_mode = 'even';
21 $div_scale = 40;
22
23 sub new
24 {
25         my $proto  = shift;
26         my $class  = ref($proto) || $proto;
27
28         my $value       = shift;
29         my $a = $accuracy; $a = $_[0] if defined $_[0];
30         my $p = $precision; $p = $_[1] if defined $_[1];
31         my $self = Math::BigInt->new($value,$a,$p,$round_mode);
32         bless $self,$class;
33         $self->{'_custom'} = 1; # make sure this never goes away
34         return $self;
35 }
36
37 sub bgcd
38   {
39   Math::BigInt::bgcd(@_);
40   }
41
42 sub blcm
43   {
44   Math::BigInt::blcm(@_);
45   }
46
47 sub import
48   {
49   my $self = shift;
50   $self->SUPER::import(@_);                     # need it for subclasses
51   #$self->export_to_level(1,$self,@_);           # need this ?
52   }
53
54 1;