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 | |
b3abae2a |
16 | $VERSION = 0.03; |
17 | |
18 | use overload; # inherit overload from BigInt |
dccbb853 |
19 | |
20 | # Globals |
21 | $accuracy = $precision = undef; |
22 | $round_mode = 'even'; |
23 | $div_scale = 40; |
24 | |
25 | sub new |
26 | { |
27 | my $proto = shift; |
28 | my $class = ref($proto) || $proto; |
29 | |
394e6ffb |
30 | my $value = shift; |
61f5c3f5 |
31 | my $a = $accuracy; $a = $_[0] if defined $_[0]; |
32 | my $p = $precision; $p = $_[1] if defined $_[1]; |
33 | my $self = Math::BigInt->new($value,$a,$p,$round_mode); |
34 | bless $self,$class; |
dccbb853 |
35 | $self->{'_custom'} = 1; # make sure this never goes away |
36 | return $self; |
37 | } |
38 | |
39 | sub bgcd |
40 | { |
41 | Math::BigInt::bgcd(@_); |
42 | } |
43 | |
44 | sub blcm |
45 | { |
46 | Math::BigInt::blcm(@_); |
47 | } |
48 | |
49 | sub import |
50 | { |
51 | my $self = shift; |
dccbb853 |
52 | $self->SUPER::import(@_); # need it for subclasses |
53 | #$self->export_to_level(1,$self,@_); # need this ? |
54 | } |
55 | |
56 | 1; |