Commit | Line | Data |
dccbb853 |
1 | #!/usr/bin/perl -w |
2 | |
3 | package Math::BigInt::Subclass; |
4 | |
5 | require 5.005_02; |
6 | use strict; |
7 | |
8 | use Exporter; |
61f5c3f5 |
9 | use Math::BigInt(1.49); |
dccbb853 |
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 | |
61f5c3f5 |
16 | $VERSION = 0.02; |
dccbb853 |
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 | |
394e6ffb |
28 | my $value = shift; |
61f5c3f5 |
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; |
dccbb853 |
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; |
dccbb853 |
50 | $self->SUPER::import(@_); # need it for subclasses |
51 | #$self->export_to_level(1,$self,@_); # need this ? |
52 | } |
53 | |
54 | 1; |