Move Math::BigInt from ext/ to cpan/
[p5sagit/p5-mst-13.2.git] / cpan / Math-BigInt / t / Math / BigFloat / Subclass.pm
CommitLineData
ee15d750 1#!/usr/bin/perl -w
2
b68b7ab1 3# for testing subclassing Math::BigFloat
4
dccbb853 5package Math::BigFloat::Subclass;
ee15d750 6
7require 5.005_02;
8use strict;
9
10use Exporter;
990fb837 11use Math::BigFloat(1.38);
dccbb853 12use vars qw($VERSION @ISA $PACKAGE
ee15d750 13 $accuracy $precision $round_mode $div_scale);
14
15@ISA = qw(Exporter Math::BigFloat);
16
b68b7ab1 17$VERSION = 0.05;
b3abae2a 18
19use overload; # inherit overload from BigInt
ee15d750 20
21# Globals
22$accuracy = $precision = undef;
23$round_mode = 'even';
24$div_scale = 40;
25
26sub new
27{
28 my $proto = shift;
29 my $class = ref($proto) || $proto;
30
394e6ffb 31 my $value = shift;
61f5c3f5 32 my $a = $accuracy; $a = $_[0] if defined $_[0];
33 my $p = $precision; $p = $_[1] if defined $_[1];
ee15d750 34 # Store the floating point value
61f5c3f5 35 my $self = Math::BigFloat->new($value,$a,$p,$round_mode);
36 bless $self, $class;
ee15d750 37 $self->{'_custom'} = 1; # make sure this never goes away
38 return $self;
39}
40
13a12e00 41BEGIN
42 {
43 *objectify = \&Math::BigInt::objectify;
b68b7ab1 44 # to allow Math::BigFloat::Subclass::bgcd( ... ) style calls
45 *bgcd = \&Math::BigFloat::bgcd;
46 *blcm = \&Math::BigFloat::blcm;
13a12e00 47 }
48
ee15d750 491;