1#!perl 2 3# for testing subclassing Math::BigFloat 4 5package Math::BigFloat::Subclass; 6 7require 5.006; 8 9use strict; 10use warnings; 11 12use Exporter; 13use Math::BigFloat 1.38; 14 15our ($accuracy, $precision, $round_mode, $div_scale); 16 17our @ISA = qw(Math::BigFloat Exporter); 18 19our $VERSION = "0.07"; 20 21use overload; # inherit overload from BigInt 22 23# Globals 24$accuracy = $precision = undef; 25$round_mode = 'even'; 26$div_scale = 40; 27 28sub new { 29 my $proto = shift; 30 my $class = ref($proto) || $proto; 31 32 my $value = shift; 33 my $a = $accuracy; $a = $_[0] if defined $_[0]; 34 my $p = $precision; $p = $_[1] if defined $_[1]; 35 # Store the floating point value 36 my $self = Math::BigFloat->new($value, $a, $p, $round_mode); 37 bless $self, $class; 38 $self->{'_custom'} = 1; # make sure this never goes away 39 return $self; 40} 41 42BEGIN { 43 *objectify = \&Math::BigInt::objectify; 44 # to allow Math::BigFloat::Subclass::bgcd( ... ) style calls 45 *bgcd = \&Math::BigFloat::bgcd; 46 *blcm = \&Math::BigFloat::blcm; 47} 48 491; 50