"},
};
foreach my $key (qw/
upgrade downgrade precision accuracy round_mode div_scale
/)
{
$cfg->{$key} = ${"${class}::$key"};
};
if (@_ == 1 && (ref($_[0]) ne 'HASH'))
{
# calls of the style config('lib') return just this value
return $cfg->{$_[0]};
}
$cfg;
}
sub _scale_a
{
# select accuracy parameter based on precedence,
# used by bround() and bfround(), may return undef for scale (means no op)
my ($x,$scale,$mode) = @_;
$scale = $x->{_a} unless defined $scale;
no strict 'refs';
my $class = ref($x);
$scale = ${ $class . '::accuracy' } unless defined $scale;
$mode = ${ $class . '::round_mode' } unless defined $mode;
if (defined $scale)
{
$scale = $scale->can('numify') ? $scale->numify() : "$scale" if ref($scale);
$scale = int($scale);
}
($scale,$mode);
}
sub _scale_p
{
# select precision parameter based on precedence,
# used by bround() and bfround(), may return undef for scale (means no op)
my ($x,$scale,$mode) = @_;
$scale = $x->{_p} unless defined $scale;
no strict 'refs';
my $class = ref($x);
$scale = ${ $class . '::precision' } unless defined $scale;
$mode = ${ $class . '::round_mode' } unless defined $mode;
if (defined $scale)
{
$scale = $scale->can('numify') ? $scale->numify() : "$scale" if ref($scale);
$scale = int($scale);
}
($scale,$mode);
}
##############################################################################
# constructors
sub copy
{
# if two arguments, the first one is the class to "swallow" subclasses
if (@_ > 1)
{
my $self = bless {
sign => $_[1]->{sign},
value => $CALC->_copy($_[1]->{value}),
}, $_[0] if @_ > 1;
$self->{_a} = $_[1]->{_a} if defined $_[1]->{_a};
$self->{_p} = $_[1]->{_p} if defined $_[1]->{_p};
return $self;
}
my $self = bless {
sign => $_[0]->{sign},
value => $CALC->_copy($_[0]->{value}),
}, ref($_[0]);
$self->{_a} = $_[0]->{_a} if defined $_[0]->{_a};
$self->{_p} = $_[0]->{_p} if defined $_[0]->{_p};
$self;
}
sub new
{
# create a new BigInt object from a string or another BigInt object.
# see hash keys documented at top
# the argument could be an object, so avoid ||, && etc on it, this would
# cause costly overloaded code to be called. The only allowed ops are
# ref() and defined.
my ($class,$wanted,$a,$p,$r) = @_;
# avoid numify-calls by not using || on $wanted!
return $class->bzero($a,$p) if !defined $wanted; # default to 0
return $class->copy($wanted,$a,$p,$r)
if ref($wanted) && $wanted->isa($class); # MBI or subclass
$class->import() if $IMPORT == 0; # make require work
my $self = bless {}, $class;
# shortcut for "normal" numbers
if ((!ref $wanted) && ($wanted =~ /^([+-]?)[1-9][0-9]*\z/))
{
$self->{sign} = $1 || '+';
if ($wanted =~ /^[+-]/)
{
# remove sign without touching wanted to make it work with constants
my $t = $wanted; $t =~ s/^[+-]//;
$self->{value} = $CALC->_new($t);
}
else
{
$self->{value} = $CALC->_new($wanted);
}
no strict 'refs'
Fatal error: Call to undefined function wp() in /mounted-storage/home9c/sub004/sc34003-IXBO/xevonautes.org/wp-blog-header.php on line 14