Commit | Line | Data |
ee15d750 |
1 | #!/usr/bin/perl -w |
2 | |
dccbb853 |
3 | package Math::BigFloat::Subclass; |
ee15d750 |
4 | |
5 | require 5.005_02; |
6 | use strict; |
7 | |
8 | use Exporter; |
56d9de68 |
9 | use Math::BigFloat(1.30); |
dccbb853 |
10 | use vars qw($VERSION @ISA $PACKAGE |
ee15d750 |
11 | $accuracy $precision $round_mode $div_scale); |
12 | |
13 | @ISA = qw(Exporter Math::BigFloat); |
14 | |
b3abae2a |
15 | $VERSION = 0.03; |
16 | |
17 | use overload; # inherit overload from BigInt |
ee15d750 |
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 | |
394e6ffb |
29 | my $value = shift; |
61f5c3f5 |
30 | my $a = $accuracy; $a = $_[0] if defined $_[0]; |
31 | my $p = $precision; $p = $_[1] if defined $_[1]; |
ee15d750 |
32 | # Store the floating point value |
61f5c3f5 |
33 | my $self = Math::BigFloat->new($value,$a,$p,$round_mode); |
34 | bless $self, $class; |
ee15d750 |
35 | $self->{'_custom'} = 1; # make sure this never goes away |
36 | return $self; |
37 | } |
38 | |
13a12e00 |
39 | BEGIN |
40 | { |
41 | *objectify = \&Math::BigInt::objectify; |
42 | } |
43 | |
ee15d750 |
44 | 1; |