1#!perl 2 3package Math::BigFloat::Trace; 4 5require 5.010; 6use strict; 7use warnings; 8 9use Exporter; 10use Math::BigFloat; 11 12our ($accuracy, $precision, $round_mode, $div_scale); 13 14our @ISA = qw(Exporter Math::BigFloat); 15 16our $VERSION = '0.51'; 17 18use overload; # inherit overload from Math::BigFloat 19 20# Globals 21$accuracy = $precision = undef; 22$round_mode = 'even'; 23$div_scale = 40; 24 25sub new { 26 my $proto = shift; 27 my $class = ref($proto) || $proto; 28 29 my $value = shift; 30 my $a = $accuracy; 31 $a = $_[0] if defined $_[0]; 32 my $p = $precision; 33 $p = $_[1] if defined $_[1]; 34 my $self = Math::BigFloat->new($value, $a, $p, $round_mode); 35 36 # remember, downgrading may return a BigInt, so don't meddle with class 37 # bless $self, $class; 38 39 print "MBF new '$value' => '$self' (", ref($self), ")"; 40 return $self; 41} 42 43sub import { 44 print "MBF import ", join(' ', @_); 45 my $self = shift; 46 47 # we catch the constants, the rest goes go BigFloat 48 my @a = (); 49 foreach (@_) { 50 push @a, $_ if $_ ne ':constant'; 51 } 52 overload::constant float => sub { $self->new(shift); }; 53 54 Math::BigFloat->import(@a); # need it for subclasses 55# $self->export_to_level(1,$self,@_); # need this ? 56} 57 581; 59