Math::BigFloat 1.998
Math::BigInt 1.9991
Math::BigInt::Calc 1.997
####
sub _len {
my $cx = $_[1];
(@$cx-1)*$BASE_LEN+length(int($cx->[-1])); # <--- line 1209
}
####
sub _digit {
my ($c,$x,$n) = @_;
my $len = _len('',$x);
...
}
####
@ISA = qw/Math::BigInt/;
####
...
my $CALC = 'Math::BigInt::Calc';
...
sub digit {
my ($self,$x,$n) = ref($_[0]) ? (undef,@_) : objectify(1,@_);
$n = $n->numify() if ref($n);
$CALC->_digit($x->{value},$n||0);
}
####
my ($self,$x,$n) = (undef, $YOUR_n, -1);
####
Math::BigInt::Calc->_digit(undef, -1);
####
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Math::BigFloat;
my $n = Math::BigFloat->new(123);
say $n;
say 'REF $n: ', ref $n;
eval {
say $n->digit(-1);
};
warn $@ if $@;
say '$n->{value} EXISTS: ', exists $n->{value} ? 'Yes' : 'No';
say '$n->{value} DEFINED: ', defined $n->{value} ? 'Yes' : 'No';
eval {
$n->{value} = [123];
say '$n->digit(-1): ', $n->digit(-1);
say '$n->digit(1): ', $n->digit(1);
say '$n->digit(): ', $n->digit();
};
warn $@ if $@;
####
123
REF $n: Math::BigFloat
Can't use an undefined value as an ARRAY reference at /Users/ken/perl5/perlbrew/perls/perl-5.18.1t/lib/5.18.1/Math/BigInt/Calc.pm line 1209.
$n->{value} EXISTS: No
$n->{value} DEFINED: No
$n->digit(-1): 1
$n->digit(1): 2
$n->digit(): 3