This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade bignum from version 0.40 to 0.41
[perl5.git] / cpan / bignum / lib / Math / BigFloat / Trace.pm
CommitLineData
126f3c5f
JH
1#!/usr/bin/perl -w
2
3package Math::BigFloat::Trace;
4
5require 5.005_02;
6use strict;
7
8use Exporter;
9use Math::BigFloat;
10use vars qw($VERSION @ISA $PACKAGE @EXPORT_OK
11 $accuracy $precision $round_mode $div_scale);
12
13@ISA = qw(Exporter Math::BigFloat);
14
c6824fe7 15$VERSION = '0.41';
126f3c5f 16
56e812ab 17use overload; # inherit overload from BigFloat
126f3c5f
JH
18
19# Globals
20$accuracy = $precision = undef;
21$round_mode = 'even';
22$div_scale = 40;
23
56e812ab
PJA
24sub new {
25 my $proto = shift;
26 my $class = ref($proto) || $proto;
126f3c5f 27
56e812ab
PJA
28 my $value = shift;
29 my $a = $accuracy;
30 $a = $_[0] if defined $_[0];
31 my $p = $precision;
32 $p = $_[1] if defined $_[1];
33 my $self = Math::BigFloat->new($value, $a, $p, $round_mode);
126f3c5f 34
56e812ab
PJA
35 # remember, downgrading may return a BigInt, so don't meddle with class
36 # bless $self, $class;
126f3c5f 37
56e812ab
PJA
38 print "MBF new '$value' => '$self' (", ref($self), ")";
39 return $self;
126f3c5f
JH
40}
41
56e812ab
PJA
42sub import {
43 print "MBF import ", join(' ', @_);
44 my $self = shift;
126f3c5f 45
56e812ab
PJA
46 # we catch the constants, the rest goes go BigFloat
47 my @a = ();
48 foreach (@_) {
49 push @a, $_ if $_ ne ':constant';
126f3c5f 50 }
56e812ab 51 overload::constant float => sub { $self->new(shift); };
126f3c5f 52
56e812ab
PJA
53 Math::BigFloat->import(@a); # need it for subclasses
54# $self->export_to_level(1,$self,@_); # need this ?
55}
126f3c5f
JH
56
571;