Move Locale::Codes from ext/ to cpan/
[p5sagit/p5-mst-13.2.git] / ext / Math-BigInt / t / Math / BigFloat / Subclass.pm
1 #!/usr/bin/perl -w
2
3 # for testing subclassing Math::BigFloat
4
5 package Math::BigFloat::Subclass;
6
7 require 5.005_02;
8 use strict;
9
10 use Exporter;
11 use Math::BigFloat(1.38);
12 use vars qw($VERSION @ISA $PACKAGE
13             $accuracy $precision $round_mode $div_scale);
14
15 @ISA = qw(Exporter Math::BigFloat);
16
17 $VERSION = 0.05;
18
19 use overload;           # inherit overload from BigInt
20
21 # Globals
22 $accuracy = $precision = undef;
23 $round_mode = 'even';
24 $div_scale = 40;
25
26 sub new
27 {
28         my $proto  = shift;
29         my $class  = ref($proto) || $proto;
30
31         my $value       = shift;
32         my $a = $accuracy; $a = $_[0] if defined $_[0];
33         my $p = $precision; $p = $_[1] if defined $_[1];
34         # Store the floating point value
35         my $self = Math::BigFloat->new($value,$a,$p,$round_mode);
36         bless $self, $class;
37         $self->{'_custom'} = 1; # make sure this never goes away
38         return $self;
39 }
40
41 BEGIN
42   {
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
49 1;