| 1 | #!/usr/bin/perl -w |
| 2 | |
| 3 | package Math::BigInt::Trace; |
| 4 | |
| 5 | require 5.005_02; |
| 6 | use strict; |
| 7 | |
| 8 | use Exporter; |
| 9 | use Math::BigInt; |
| 10 | use vars qw($VERSION @ISA $PACKAGE @EXPORT_OK |
| 11 | $accuracy $precision $round_mode $div_scale); |
| 12 | |
| 13 | @ISA = qw(Exporter Math::BigInt); |
| 14 | |
| 15 | $VERSION = 0.01; |
| 16 | |
| 17 | use overload; # inherit overload from BigInt |
| 18 | |
| 19 | # Globals |
| 20 | $accuracy = $precision = undef; |
| 21 | $round_mode = 'even'; |
| 22 | $div_scale = 40; |
| 23 | |
| 24 | sub new |
| 25 | { |
| 26 | my $proto = shift; |
| 27 | my $class = ref($proto) || $proto; |
| 28 | |
| 29 | my $value = shift; |
| 30 | my $a = $accuracy; $a = $_[0] if defined $_[0]; |
| 31 | my $p = $precision; $p = $_[1] if defined $_[1]; |
| 32 | my $self = Math::BigInt->new($value,$a,$p,$round_mode); |
| 33 | bless $self,$class; |
| 34 | print "MBI new '$value' => '$self' (",ref($self),")"; |
| 35 | return $self; |
| 36 | } |
| 37 | |
| 38 | sub import |
| 39 | { |
| 40 | print "MBI import ",join(' ',@_); |
| 41 | my $self = shift; |
| 42 | Math::BigInt::import($self,@_); # need it for subclasses |
| 43 | # $self->export_to_level(1,$self,@_); # need this ? |
| 44 | @_ = (); |
| 45 | } |
| 46 | |
| 47 | 1; |