| 1 | # For speed and simplicity, a Math::BigInt::Lite object is a reference to a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # scalar. When something more complex needs to happen (like +inf,-inf, NaN or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # rounding), Math::BigInt::Lite objects are upgraded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package Math::BigInt::Lite; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | require 5.006001; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use Scalar::Util qw< blessed >; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | ▶ | use Math::BigInt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | our ($_trap_inf, $_trap_nan); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | our @ISA = qw(Math::BigInt Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 6 | our @EXPORT_OK = qw/objectify/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 6 | my $class = 'Math::BigInt::Lite'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 6 | our $VERSION = '0.30'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # global constants, flags and accessory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 6 | our $accuracy = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | our $precision = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 6 | our $round_mode = 'even'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 6 | our $div_scale = 40; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 6 | our $upgrade = 'Math::BigInt'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | our $downgrade = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 6 | my $nan = 'NaN'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 6 | my $MAX_NEW_LEN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | my $MAX_MUL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 6 | my $MAX_ADD; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | my $MAX_BIN_LEN = 31; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 6 | my $MAX_OCT_LEN = 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 6 | my $MAX_HEX_LEN = 7; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 6 | my $e0 = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | my $e1 = $e0 + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 6 | my $num; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 6 | $num = '9' x $e1; # maximum value in base 10**$e1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 54 | $num = $num * $num # multiply by itself | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | + ($num - 1); # largest possible carry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 54 | ▶ | last if $num !~ /^9{$e0}89{$e1}$/; # check digit pattern | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 48 | $e0 = $e1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 48 | $e1++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 48 | redo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 6 | my $e = $e0; # $e1 is one too large | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # the limits below brush the problems with the test above under the rug: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # the test should be able to find the proper $e automatically | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 6 | ▶ | $e = 5 if $^O =~ /^uts/; # UTS get's some special treatment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 6 | ▶ | $e = 5 if $^O =~ /^unicos/; # unicos is also problematic (6 seems to work | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # there, but we play safe) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 6 | ▶ | $e = 8 if $e > 8; # cap, for VMS, OS/390 and other 64 bit systems | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 6 | my $bi = $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # # determine how many digits fit into an integer and can be safely added | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # # together plus carry w/o causing an overflow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # # this below detects 15 on a 64 bit system, because after that it becomes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # # 1e16 and not 1000000 :/ I can make it detect 18, but then I get a lot of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # # test failures. Ugh! (Tomake detect 18: uncomment lines marked with *) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # use integer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # my $bi = 5; # approx. 16 bit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # $num = int('9' x $bi); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # # $num = 99999; # * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # # while ( ($num+$num+1) eq '1' . '9' x $bi) # * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # while ( int($num+$num+1) eq '1' . '9' x $bi) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # $bi++; $num = int('9' x $bi); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # # $bi++; $num *= 10; $num += 9; # * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # $bi--; # back off one step | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # we ensure that every number created is below the length for the add, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # that it is always safe to add two objects together | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 6 | $MAX_NEW_LEN = $bi; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # The constant below is used to check the result of any add, if above, we | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # need to upgrade. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 6 | $MAX_ADD = int("1E$bi"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # For mul, we need to check *before* the operation that both operands are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # below the number benlow, since otherwise it could overflow. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 6 | $MAX_MUL = int("1E$e"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # print "MAX_NEW_LEN $MAX_NEW_LEN MAX_ADD $MAX_ADD MAX_MUL $MAX_MUL\n\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # we tie our accuracy/precision/round_mode to BigInt, so that setting it here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # will do it in BigInt, too. You can't use Lite w/o BigInt, anyway. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 77 | ▶ | sub round_mode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
round_mode: called CC=5 SCAR=17.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 6 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # make Class->round_mode() work | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 77 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 77 | ▶ | my $class = ref($self) || $self || __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
ref $self || $self || __PACKAGE__
ref $self or $self
MC/DC0%0/2
ref $self || $self || __PACKAGE__
ref $self
$self
Truth table33%1/3
A or B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 77 | ▶ | if (defined $_[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 77 | my $m = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 77 | ▶ | die "Unknown round mode $m" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | if $m !~ /^(even|odd|\+inf|\-inf|zero|trunc|common)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # set in BigInt, too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 77 | Math::BigInt->round_mode($m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 77 | return ${"${class}::round_mode"} = $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return ${"${class}::round_mode"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub accuracy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accuracy: not called CC=10 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # $x->accuracy($a); ref($x) $a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # $x->accuracy(); ref($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # Class->accuracy(); class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # Class->accuracy($a); class $a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | my $class = ref($x) || $x || __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
ref $x || $x || __PACKAGE__
ref $x or $x
MC/DC0%0/2
ref $x || $x || __PACKAGE__
ref $x
$x
Truth table0%0/3
A or B
A= ref $xB= $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 6 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # need to set new value? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if (@_ > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $a = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | die ('accuracy must not be zero') if defined $a && $a == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $a and $a == 0
MC/DC0%0/2
defined $a and $a == 0
defined $a
$a == 0
Truth table0%0/3
A and B
A= defined $aB= $a == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if (ref($x)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # $object->accuracy() or fallback to global | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | $x->bround($a) if defined $a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $x->{_a} = $a; # set/overwrite, even if not rounded | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $x->{_p} = undef; # clear P | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # set global | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | Math::BigInt->accuracy($a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # and locally here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $accuracy = $a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $precision = undef; # clear P | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | return $a; # shortcut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if (ref($x)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # $object->accuracy() or fallback to global | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | return $x->{_a} || ${"${class}::accuracy"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$x->{'_a'} || ${"${class}::accuracy";}
MC/DC0%0/2
$x->{'_a'} || ${"${class}::accuracy";}
$x->{'_a'}
${"${class}::accuracy";}
Truth table0%0/3
A || B
A= $x->{'_a'}B= ${"${class}::accuracy";}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return ${"${class}::accuracy"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub precision { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
precision: not called CC=8 SCAR=40.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # $x->precision($p); ref($x) $p | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # $x->precision(); ref($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # Class->precision(); class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # Class->precision($p); class $p | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | my $class = ref($x) || $x || __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
ref $x || $x || __PACKAGE__
ref $x or $x
MC/DC0%0/2
ref $x || $x || __PACKAGE__
ref $x
$x
Truth table0%0/3
A or B
A= ref $xB= $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 6 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # need to set new value? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if (@_ > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $p = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if (ref($x)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # $object->precision() or fallback to global | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | $x->bfround($p) if defined $p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $x->{_p} = $p; # set/overwrite, even if not rounded | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $x->{_a} = undef; # clear A | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | Math::BigInt->precision($p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # and locally here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $accuracy = undef; # clear A | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $precision = $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | return $p; # shortcut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if (ref($x)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # $object->precision() or fallback to global | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | return $x->{_p} || ${"${class}::precision"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$x->{'_p'} || ${"${class}::precision";}
MC/DC0%0/2
$x->{'_p'} || ${"${class}::precision";}
$x->{'_p'}
${"${class}::precision";}
Truth table0%0/3
A || B
A= $x->{'_p'}B= ${"${class}::precision";}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | return ${"${class}::precision"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | use overload | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 6 | ▶ | '+' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.9
Subroutine
__ANON__: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 9 | my $x = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 9 | my $y = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 9 | my $class = ref $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 9 | ▶ | $y = $class->new($y) unless ref($y); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 9 | ▶ | if ($y->isa($class)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 9 | $x = \($$x + $$y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 9 | bless $x, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 9 | ▶ | $x = $upgrade->new($$x) if abs($$x) >= $MAX_ADD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $x = $upgrade->new($$x)->badd($y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 9 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | ▶ | '*' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 2 | my $x = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | my $y = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | my $class = ref $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | ▶ | $y = $class->new($y) unless ref($y); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | ▶ | if ($y->isa($class)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | $x = \($$x * $$y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | ▶ | $$x = 0 if $$x eq '-0'; # correct 5.x.x bug | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | bless $x, $class; # inline copy | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $x = $upgrade->new(${$_[0]})->bmul($y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # some shortcuts for speed (assumes that reversed order of arguments is routed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | # to normal '+' and we thus can always modify first arg. If this is changed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # this breaks and must be adjusted.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | #'/=' => sub { scalar $_[0]->bdiv($_[1]); }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | #'*=' => sub { $_[0]->bmul($_[1]); }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | #'+=' => sub { $_[0]->badd($_[1]); }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | #'-=' => sub { $_[0]->bsub($_[1]); }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | #'%=' => sub { $_[0]->bmod($_[1]); }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | #'&=' => sub { $_[0]->band($_[1]); }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | #'^=' => sub { $_[0]->bxor($_[1]); }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | #'|=' => sub { $_[0]->bior($_[1]); }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | #'**=' => sub { $upgrade->bpow($_[0], $_[1]); }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | '<=>' => sub { my $cmp = $_[0] -> bcmp($_[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | defined($cmp) && $_[2] ? -$cmp : $cmp; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $cmp and $_[2]
MC/DC0%0/2
defined $cmp and $_[2]
defined $cmp
$_[2]
Truth table0%0/3
A and B
A= defined $cmpB= $_[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 343 | ▶ | '""' => sub { "${$_[0]}"; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 21 | ▶ | '0+' => sub { ${$_[0]}; }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | '++' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ${$_[0]}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | return $upgrade->new(${$_[0]}) if ${$_[0]} >= $MAX_ADD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | '--' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ${$_[0]}--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | return $upgrade->new(${$_[0]}) if ${$_[0]} <= -$MAX_ADD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # fake HASH reference, so that Math::BigInt::Lite->new(123)->{sign} works | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 19 | ▶ | '%{}' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 19 | ▶ | sign => ($_[0] < 0) ? '-' : '+', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 6 | ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 6 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 6 | *objectify = \&Math::BigInt::objectify; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 2 | ▶ | sub config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: called CC=7 SCAR=26.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # config({a => b, ...}) -> config(a => b, ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | @_ = %{ $_[0] } if @_ == 1 && ref($_[0]) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # Getter/accessor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2 | ▶ | if (@_ == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | my $param = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # We don't use a math backend library. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 2 | ▶ | return if ($param eq 'lib' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$param eq "lib" or $param eq "lib_version"
MC/DC50%1/2
$param eq "lib" or $param eq "lib_version"
$param eq "lib"
$param eq "lib_version"
Truth table66%2/3
A or B
A= $param eq "lib"B= $param eq "lib_version"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | $param eq 'lib_version'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | return $class -> SUPER::config($param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # Setter. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | $class -> SUPER::config(@_) if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # For backwards compatibility. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my $cfg = Math::BigInt -> config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $cfg->{version} = $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $cfg->{lib} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $cfg->{lib_version} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $cfg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 26 | ▶ | sub bgcd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bgcd: called CC=12 SCAR=25.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # Convert calls like Class::method(2) into Class->method(2). It ignores | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # cases like Class::method($x), where $x is an object, because this is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # indistinguishable from $x->method(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 26 | ▶ | unless (@_ && (ref($_[0]) || $_[0] =~ /^[a-z]\w*(?:::[a-z]\w*)*$/i)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
@_ and ref $_[0] || $_[0] =~ /^[a-z]\w*(?:::[a-z]\w*)*$/i
ref $_[0] or $_[0] =~ /^[a-z]\w*(?:::[a-z]\w*)*$/i
MC/DC0%0/3
@_ and ref $_[0] || $_[0] =~ /^[a-z]\w*(?:::[a-z]\w*)*$/i
@_
ref $_[0]
$_[0] =~ /^[a-z]\w*(?:::[a-z]\w*)*$/i
Truth table25%1/4
A and B or C
A= @_B= ref $_[0]C= $_[0] =~ /^[a-z]\w*(?:::[a-z]\w*)*$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | #carp "Using ", (caller(0))[3], "() as a function is deprecated;", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # " use is as a method instead" if warnings::warnif("deprecated"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | unshift @_, __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # Make sure each argument is an object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 26 | my ($class, @args) = objectify(0, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | # If bgcd() is called as a function, the class might be anything. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 26 | ▶ | return $class -> bgcd(@args) unless $class -> isa(__PACKAGE__); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | # Upgrade if one of the operands are upgraded. This is for cases like | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # $x = Math::BigInt::Lite::bgcd("1e50"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # $gcd = Math::BigInt::Lite::bgcd(5, $x); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # $gcd = Math::BigInt::Lite->bgcd(5, $x); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 26 | my $do_upgrade = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 26 | for my $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 47 | ▶ | unless ($arg -> isa($class)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 10 | $do_upgrade = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 10 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 26 | ▶ | return $upgrade -> bgcd(@args) if $do_upgrade; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # Now compute the GCD. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 16 | my ($a, $b, $c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 16 | $a = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 16 | $a = abs($$a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 16 | ▶ | while (@args && $a != 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@args and $a != 1
MC/DC100%2/2
@args and $a != 1
@args
$a != 1
Truth table100%3/3
A and B
A= @argsB= $a != 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 16 | $b = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 16 | ▶ | next if $$b == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 15 | $b = abs($$b); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 15 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 44 | $c = $a % $b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 44 | $a = $b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 44 | $b = $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } while $c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 16 | return bless \( $a ), $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 8 | ▶ | sub blcm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
blcm: called CC=7 SCAR=21.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # Convert calls like Class::method(2) into Class->method(2). It ignores | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | # cases like Class::method($x), where $x is an object, because this is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | # indistinguishable from $x->method(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 8 | ▶ | unless (@_ && (ref($_[0]) || $_[0] =~ /^[a-z]\w*(?:::[a-z]\w*)*$/i)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
@_ and ref $_[0] || $_[0] =~ /^[a-z]\w*(?:::[a-z]\w*)*$/i
ref $_[0] or $_[0] =~ /^[a-z]\w*(?:::[a-z]\w*)*$/i
MC/DC0%0/3
@_ and ref $_[0] || $_[0] =~ /^[a-z]\w*(?:::[a-z]\w*)*$/i
@_
ref $_[0]
$_[0] =~ /^[a-z]\w*(?:::[a-z]\w*)*$/i
Truth table25%1/4
A and B or C
A= @_B= ref $_[0]C= $_[0] =~ /^[a-z]\w*(?:::[a-z]\w*)*$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | #carp "Using ", (caller(0))[3], "() as a function is deprecated;", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # " use is as a method instead" if warnings::warnif("deprecated"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | unshift @_, __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | # Make sure each argument is an object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 8 | my ($class, @args) = objectify(0, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 8 | my @a = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 8 | for my $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 16 | ▶ | $arg = $upgrade -> new("$arg") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined builtin::blessed($arg) and $arg->isa($Math::BigInt::Lite::upgrade)
MC/DC50%1/2
defined builtin::blessed($arg) and $arg->isa($Math::BigInt::Lite::upgrade)
defined builtin::blessed($arg)
$arg->isa($Math::BigInt::Lite::upgrade)
Truth table66%2/3
A and B
A= defined builtin::blessed($arg)B= $arg->isa($Math::BigInt::Lite::upgrade)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | unless defined(blessed($arg)) && $arg -> isa($upgrade); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 16 | push @a, $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 8 | $upgrade -> blcm(@a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 25388 | ▶ | sub isa { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isa: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | # we aren't a BigInt nor BigRat/BigFloat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 25388 | ▶ | $_[1] =~ /^Math::BigInt::Lite/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 14379 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 14379 | my ($class, $wanted, @r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 14379 | ▶ | return $upgrade->new($wanted) if !defined $wanted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # 1e12, NaN, inf, 0x12, 0b11, 1.2e2, "12345678901234567890" etc all upgrade | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 14379 | ▶ | if (!ref($wanted)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 14379 | ▶ | if ((length($wanted) <= $MAX_NEW_LEN) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
CORE::length $wanted <= $MAX_NEW_LEN and $wanted =~ /^[+-]?[0-9]{1,$MAX_NEW_LEN}(\.0*)?\z/
MC/DC100%2/2
CORE::length $wanted <= $MAX_NEW_LEN and $wanted =~ /^[+-]?[0-9]{1,$MAX_NEW_LEN}(\.0*)?\z/
CORE::length $wanted <= $MAX_NEW_LEN
$wanted =~ /^[+-]?[0-9]{1,$MAX_NEW_LEN}(\.0*)?\z/
Truth table100%3/3
A and B
A= CORE::length $wanted <= $MAX_NEW_LENB= $wanted =~ /^[+-]?[0-9]{1,$MAX_NEW_LEN}(\.0*)?\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | ($wanted =~ /^[+-]?[0-9]{1,$MAX_NEW_LEN}(\.0*)?\z/)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 12716 | my $a = \($wanted+0); # +0 to make a copy and force it numeric | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 12716 | return bless $a, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # TODO: 1e10 style constants that are still below MAX_NEW | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 1663 | ▶ | if ($wanted =~ /^([+-])?([0-9]+)[eE][+]?([0-9]+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 37 | ▶ | if ((length($2) + $3) < $MAX_NEW_LEN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 28 | my $a = \($wanted+0); # +0 to make a copy and force it numeric | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 28 | return bless $a, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # print "new '$$a' $BASE_LEN ($wanted)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 1635 | $upgrade->new($wanted, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | # String conversion methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 2960 | ▶ | sub bstr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bstr: called CC=4 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 2960 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 2960 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table33%1/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 2960 | "$$x"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # Scientific notation with significand/mantissa as an integer, e.g., "12345" is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # written as "1.2345e+4". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 627 | ▶ | sub bsstr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bsstr: called CC=5 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 627 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 627 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table33%1/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 627 | ▶ | if ($$x =~ / ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | [+-]? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | (?: 0 | [1-9] (?: \d* [1-9] )? ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | ( 0* ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | /x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 627 | my $mant = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 627 | my $expo = CORE::length($2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 627 | return $mant . "e+" . $expo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | die "Internal error: ", (caller(0))[3], "() couldn't handle", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | " the value '", $$x, "', which is likely a bug"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # Normalized notation, e.g., "12345" is written as "1.2345e+4". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | sub bnstr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bnstr: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | my ($class, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table0%0/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my ($mant, $expo); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | if ($$x =~ / ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | [+-]? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | \d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | ( 0* ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | /x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | return $1 . "e+" . CORE::length($2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | if ($$x =~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | / ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | ( [+-]? [1-9] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | ( \d* [1-9] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | /x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | return $1 . "." . $3 . "e+" . CORE::length($2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | die "Internal error: ", (caller(0))[3], "() couldn't handle", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | " the value '", $$x, "', which is likely a bug"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # Engineering notation, e.g., "12345" is written as "12.345e+3". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | sub bestr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bestr: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | my ($class, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table0%0/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | if ($$x =~ / ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | ( [+-]? ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | [1-9] (?: \d* [1-9] )? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | ( 0* ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | /x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | my $sign = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | my $mant = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | my $expo = CORE::length($3); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $mantlen = CORE::length($mant); # length of mantissa | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $expo += $mantlen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my $dotpos = ($expo - 1) % 3 + 1; # offset of decimal point | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | $expo -= $dotpos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | if ($dotpos < $mantlen) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | substr $mant, $dotpos, 0, "."; # insert decimal point | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } elsif ($dotpos > $mantlen) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $mant .= "0" x ($dotpos - $mantlen); # append zeros | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | return ($sign eq '-' ? '-' : '') . $mant . 'e+' . $expo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | die "Internal error: ", (caller(0))[3], "() couldn't handle", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | " the value '", $$x, "', which is likely a bug"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # Decimal notation, e.g., "12345" (no exponent). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | sub bdstr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bdstr: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | my ($class, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table0%0/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | "$$x"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # Fraction notation, e.g., "123.4375" is written as "1975/16", but "123" is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | # written as "123", not "123/1". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 2 | ▶ | sub bfstr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bfstr: called CC=4 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 2 | ▶ | my ($class, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 2 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table33%1/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 2 | "$$x"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 211 | ▶ | sub bnorm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bnorm: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | # no-op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 211 | ▶ | my $x = ref($_[0]) ? $_[0] : $_[0]->new($_[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 211 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 398 | ▶ | sub _upgrade_2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upgrade_2: called CC=14 SCAR=28.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | # This takes the two possible arguments, and checks them. It uses new() to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | # convert literals to objects first. Then it upgrades the operation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # when it detects that: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | # * one or both of the argument(s) is/are BigInt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | # * global A or P are set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # Input arguments: x, y, a, p, r | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # Output: flag (1: need to upgrade, 0: need not), x, y, $a, $p, $r | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | # Math::BigInt::Lite->badd(1, 2) style calls | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 398 | ▶ | shift if !ref($_[0]) && $_[0] =~ /^Math::BigInt::Lite/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not ref $_[0] and $_[0] =~ /^Math::BigInt::Lite/
MC/DC50%1/2
not ref $_[0] and $_[0] =~ /^Math::BigInt::Lite/
not ref $_[0]
$_[0] =~ /^Math::BigInt::Lite/
Truth table66%2/3
not(A) and B
A= not ref $_[0]B= $_[0] =~ /^Math::BigInt::Lite/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 398 | my ($x, $y, @r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 398 | my $up = 0; # default: don't upgrade | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 398 | ▶ | $up = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $r[0] or defined $r[1] or defined $Math::BigInt::Lite::accuracy or defined $Math::BigInt::Lite::precision
defined $r[0] or defined $r[1] or defined $Math::BigInt::Lite::accuracy
defined $r[0] or defined $r[1]
MC/DC0%0/4
defined $r[0] or defined $r[1] or defined $Math::BigInt::Lite::accuracy or defined $Math::BigInt::Lite::precision
defined $r[0]
defined $r[1]
defined $Math::BigInt::Lite::accuracy
defined $Math::BigInt::Lite::precision
Truth table20%1/5
A or B or C or D
A= defined $r[0]B= defined $r[1]C= defined $Math::BigInt::Lite::accuracyD= defined $Math::BigInt::Lite::precision
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | if (defined $r[0] || defined $r[1] || defined $accuracy || defined $precision); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 398 | ▶ | $x = __PACKAGE__->new($x) unless ref $x; # upgrade literals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 398 | ▶ | $y = __PACKAGE__->new($y) unless ref $y; # upgrade literals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 398 | ▶ | $up = 1 unless $x->isa($class) && $y->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$x->isa($class) and $y->isa($class)
MC/DC50%1/2
$x->isa($class) and $y->isa($class)
$x->isa($class)
$y->isa($class)
Truth table66%2/3
A and B
A= $x->isa($class)B= $y->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | # no need to check for overflow for add/sub/div/mod math | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 398 | ▶ | if ($up == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 45 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 45 | ▶ | $y = $upgrade->new($$y) if $y->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 398 | ($up, $x, $y, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 37 | ▶ | sub _upgrade_2_mul { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upgrade_2_mul: called CC=17 SCAR=31.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # This takes the two possible arguments, and checks them. It uses new() to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # convert literals to objects first. Then it upgrades the operation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | # when it detects that: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | # * one or both of the argument(s) is/are BigInt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | # * global A or P are set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | # * One of the arguments is too large for the operation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | # Input arguments: x, y, a, p, r | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | # Output: flag (1: need to upgrade, 0: need not), x, y, $a, $p, $r | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | # Math::BigInt::Lite->badd(1, 2) style calls | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 37 | ▶ | shift if !ref($_[0]) && $_[0] =~ /^Math::BigInt::Lite/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not ref $_[0] and $_[0] =~ /^Math::BigInt::Lite/
MC/DC50%1/2
not ref $_[0] and $_[0] =~ /^Math::BigInt::Lite/
not ref $_[0]
$_[0] =~ /^Math::BigInt::Lite/
Truth table66%2/3
not(A) and B
A= not ref $_[0]B= $_[0] =~ /^Math::BigInt::Lite/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 37 | my ($x, $y, @r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 37 | my $up = 0; # default: don't upgrade | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 37 | ▶ | $up = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $r[0] or defined $r[1] or defined $Math::BigInt::Lite::accuracy or defined $Math::BigInt::Lite::precision
defined $r[0] or defined $r[1] or defined $Math::BigInt::Lite::accuracy
defined $r[0] or defined $r[1]
MC/DC0%0/4
defined $r[0] or defined $r[1] or defined $Math::BigInt::Lite::accuracy or defined $Math::BigInt::Lite::precision
defined $r[0]
defined $r[1]
defined $Math::BigInt::Lite::accuracy
defined $Math::BigInt::Lite::precision
Truth table20%1/5
A or B or C or D
A= defined $r[0]B= defined $r[1]C= defined $Math::BigInt::Lite::accuracyD= defined $Math::BigInt::Lite::precision
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | if (defined $r[0] || defined $r[1] || defined $accuracy || defined $precision); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 37 | ▶ | $x = __PACKAGE__->new($x) unless ref $x; # upgrade literals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 37 | ▶ | $y = __PACKAGE__->new($y) unless ref $y; # upgrade literals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 37 | ▶ | $up = 1 unless $x->isa($class) && $y->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$x->isa($class) and $y->isa($class)
MC/DC50%1/2
$x->isa($class) and $y->isa($class)
$x->isa($class)
$y->isa($class)
Truth table66%2/3
A and B
A= $x->isa($class)B= $y->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 37 | ▶ | $up = 1 if ($up == 0 && (abs($$x) >= $MAX_MUL || abs($$y) >= $MAX_MUL) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$up == 0 and abs $$x >= $MAX_MUL || abs $$y >= $MAX_MUL
abs $$x >= $MAX_MUL or abs $$y >= $MAX_MUL
MC/DC0%0/3
$up == 0 and abs $$x >= $MAX_MUL || abs $$y >= $MAX_MUL
$up == 0
abs $$x >= $MAX_MUL
abs $$y >= $MAX_MUL
Truth table50%2/4
A and B or C
A= $up == 0B= abs $$x >= $MAX_MULC= abs $$y >= $MAX_MUL
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 37 | ▶ | if ($up == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 3 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 3 | ▶ | $y = $upgrade->new($$y) if $y->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 37 | ($up, $x, $y, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 6 | ▶ | sub _upgrade_1 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upgrade_1: called CC=9 SCAR=28.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | # This takes the one possible argument, and checks it. It uses new() to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | # convert a literal to an object first. Then it checks for a necc. upgrade: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | # * the argument is a BigInt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | # * global A or P are set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | # Input arguments: x, a, p, r | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | # Output: flag (1: need to upgrade, 0: need not), x, $a, $p, $r | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 6 | my ($x, @r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 6 | my $up = 0; # default: don't upgrade | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 6 | ▶ | $up = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $r[0] or defined $r[1] or defined $Math::BigInt::Lite::accuracy or defined $Math::BigInt::Lite::precision
defined $r[0] or defined $r[1] or defined $Math::BigInt::Lite::accuracy
defined $r[0] or defined $r[1]
MC/DC0%0/4
defined $r[0] or defined $r[1] or defined $Math::BigInt::Lite::accuracy or defined $Math::BigInt::Lite::precision
defined $r[0]
defined $r[1]
defined $Math::BigInt::Lite::accuracy
defined $Math::BigInt::Lite::precision
Truth table20%1/5
A or B or C or D
A= defined $r[0]B= defined $r[1]C= defined $Math::BigInt::Lite::accuracyD= defined $Math::BigInt::Lite::precision
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | if (defined $r[0] || defined $r[1] || defined $accuracy || defined $precision); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 6 | ▶ | $x = __PACKAGE__->new($x) unless ref $x; # upgrade literals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 6 | ▶ | $up = 1 unless $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 6 | ▶ | if ($up == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 6 | ($up, $x, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # rounding functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 9 | ▶ | sub bround { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bround: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 9 | ▶ | my ($class, $x, @a) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | #$m = $self->round_mode() if !defined $m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | #$a = $self->accuracy() if !defined $a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 9 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 9 | $x->bround(@a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 1 | ▶ | sub bfround { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bfround: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 1 | ▶ | my ($class, $x, @p) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | #$m = $self->round_mode() if !defined $m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | #$p = $self->precision() if !defined $p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 1 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 1 | $x->bfround(@p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 2 | ▶ | sub round { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
round: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 2 | ▶ | my ($class, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 2 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 2 | $x->round(@r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | # special values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 5 | ▶ | sub bnan { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bnan: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | # return a NaN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 5 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 5 | $upgrade -> bnan(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 17 | ▶ | sub binf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binf: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | # return a +/-Inf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 17 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 17 | $upgrade -> binf(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 12 | ▶ | sub bone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bone: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | # return a +/-1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 12 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 12 | my ($sign, @r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | # Get the sign. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 12 | ▶ | if (defined($_[0]) && $_[0] =~ /^\s*([+-])\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $_[0] and $_[0] =~ /^\s*([+-])\s*$/
MC/DC100%2/2
defined $_[0] and $_[0] =~ /^\s*([+-])\s*$/
defined $_[0]
$_[0] =~ /^\s*([+-])\s*$/
Truth table100%3/3
A and B
A= defined $_[0]B= $_[0] =~ /^\s*([+-])\s*$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 8 | $sign = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 8 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 4 | $sign = '+'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 12 | ▶ | my $num = $sign eq "-" ? -1 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 12 | ▶ | return $x -> new($num) unless ref $x; # $class->bone(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 6 | $$x = $num; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 6 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 3 | ▶ | sub bzero { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bzero: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | # return a one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 3 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 3 | ▶ | return $x->new(0) unless ref $x; # $class->bone(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 1 | $$x = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 1 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 95 | ▶ | sub bcmp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bcmp: called CC=6 SCAR=18.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | # compare the value of two objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 95 | ▶ | my ($class, $x, $y, @r) = ref($_[0]) && ref($_[0]) eq ref($_[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $_[0] and ref $_[0] eq ref $_[1]
MC/DC50%1/2
ref $_[0] and ref $_[0] eq ref $_[1]
ref $_[0]
ref $_[0] eq ref $_[1]
Truth table66%2/3
A and B
A= ref $_[0]B= ref $_[0] eq ref $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | ? (ref($_[0]), @_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | : objectify(2, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 95 | ▶ | return $upgrade->bcmp($x, $y) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $Math::BigInt::Lite::upgrade and not $x->isa($class) && $y->isa($class)
$x->isa($class) && $y->isa($class)
MC/DC33%1/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class) && $y->isa($class)
defined $Math::BigInt::Lite::upgrade
$x->isa($class)
$y->isa($class)
Truth table50%2/4
A and not(B && C)
A= defined $Math::BigInt::Lite::upgradeB= $x->isa($class)C= $y->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | if defined($upgrade) && (!$x->isa($class) || !$y->isa($class)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 90 | $$x <=> $$y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 12 | ▶ | sub bacmp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bacmp: called CC=6 SCAR=18.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | # compare the absolute value of two objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 12 | ▶ | my ($class, $x, $y, @r) = ref($_[0]) && ref($_[0]) eq ref($_[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $_[0] and ref $_[0] eq ref $_[1]
MC/DC50%1/2
ref $_[0] and ref $_[0] eq ref $_[1]
ref $_[0]
ref $_[0] eq ref $_[1]
Truth table66%2/3
A and B
A= ref $_[0]B= ref $_[0] eq ref $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | ? (ref($_[0]), @_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | : objectify(2, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 12 | ▶ | return $upgrade->bacmp($x, $y) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $Math::BigInt::Lite::upgrade and not $x->isa($class) && $y->isa($class)
$x->isa($class) && $y->isa($class)
MC/DC33%1/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class) && $y->isa($class)
defined $Math::BigInt::Lite::upgrade
$x->isa($class)
$y->isa($class)
Truth table50%2/4
A and not(B && C)
A= defined $Math::BigInt::Lite::upgradeB= $x->isa($class)C= $y->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | if defined($upgrade) && (!$x->isa($class) || !$y->isa($class)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 7 | abs($$x) <=> abs($$y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | # copy/conversion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 289 | ▶ | sub copy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy: called CC=2 SCAR=7.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 289 | my ($x, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 289 | ▶ | if (ref($_[0])) { # $y = $x -> copy() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 289 | $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 289 | $class = ref($x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } else { # $y = $class -> copy($y) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 289 | my $val = $$x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 289 | bless \$val, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 624 | ▶ | sub as_int { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_int: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 624 | ▶ | my ($class, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 624 | ▶ | return $x -> copy() if $x -> isa("Math::BigInt"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | # disable upgrading and downgrading | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 624 | my $upg = Math::BigInt -> upgrade(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 624 | my $dng = Math::BigInt -> downgrade(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 624 | Math::BigInt -> upgrade(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 624 | Math::BigInt -> downgrade(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 624 | my $y = Math::BigInt -> new($x -> bsstr()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | # reset upgrading and downgrading | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 624 | Math::BigInt -> upgrade($upg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 624 | Math::BigInt -> downgrade($dng); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 624 | return $y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 1 | ▶ | sub as_number { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_number: called CC=4 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 1 | ▶ | my ($class, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 1 | ▶ | return $upgrade->new($x) unless ref($x); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | # as_number needs to return a BigInt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 1 | ▶ | return $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | $x->copy(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 81 | ▶ | sub numify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
numify: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 81 | ▶ | my ($class, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 81 | ▶ | return $$x if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | $x->numify(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 5 | ▶ | sub as_hex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_hex: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 5 | ▶ | my ($class, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 5 | ▶ | return $upgrade->new($$x)->as_hex() if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | $x->as_hex(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 5 | ▶ | sub as_oct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_oct: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 5 | ▶ | my ($class, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 5 | ▶ | return $upgrade->new($$x)->as_oct() if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | $x->as_hex(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 5 | ▶ | sub as_bin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_bin: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 5 | ▶ | my ($class, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 5 | ▶ | return $upgrade->new($$x)->as_bin() if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | $x->as_bin(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | ▶ | sub from_hex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_hex: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | my $selfref = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | ▶ | my $class = $selfref || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$selfref || $self
MC/DC0%0/2
$selfref || $self
$selfref
$self
Truth table0%0/3
A || B
A= $selfrefB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | # If called as a class method, initialize a new object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | ▶ | $self = $class -> bzero() unless $selfref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | ▶ | if ($str =~ s/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | ( [+-]? ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | ( 0? [Xx] )? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | [0-9a-fA-F]* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | ( _ [0-9a-fA-F]+ )* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | //x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | # Get a "clean" version of the string, i.e., non-emtpy and with no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | # underscores or invalid characters. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | my $sign = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | my $chrs = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | $chrs =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | ▶ | $chrs = '0' unless CORE::length $chrs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | ▶ | return $upgrade -> from_hex($sign . $chrs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | if length($chrs) > $MAX_HEX_LEN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | $$self = oct('0x' . $chrs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | ▶ | $$self = -$$self if $sign eq '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | # For consistency with from_hex() and from_oct(), we return NaN when the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | # input is invalid. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | return $self->bnan(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | sub from_oct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_oct: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | my $selfref = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | my $class = $selfref || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$selfref || $self
MC/DC0%0/2
$selfref || $self
$selfref
$self
Truth table0%0/3
A || B
A= $selfrefB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | # If called as a class method, initialize a new object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | ▶ | $self = $class -> bzero() unless $selfref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | ▶ | if ($str =~ s/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | ( [+-]? ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | ( 0? [Oo] )? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | [0-7]* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | ( _ [0-7]+ )* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | //x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | # Get a "clean" version of the string, i.e., non-emtpy and with no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | # underscores or invalid characters. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | my $sign = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | my $chrs = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | $chrs =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | ▶ | $chrs = '0' unless CORE::length $chrs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | ▶ | return $upgrade -> from_oct($sign . $chrs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | if length($chrs) > $MAX_OCT_LEN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | $$self = oct($chrs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | ▶ | $$self = -$$self if $sign eq '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | # For consistency with from_hex() and from_oct(), we return NaN when the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | # input is invalid. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | return $self->bnan(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | ▶ | sub from_bin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_bin: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | my $selfref = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | ▶ | my $class = $selfref || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$selfref || $self
MC/DC0%0/2
$selfref || $self
$selfref
$self
Truth table0%0/3
A || B
A= $selfrefB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | # If called as a class method, initialize a new object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | ▶ | $self = $class -> bzero() unless $selfref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | ▶ | if ($str =~ s/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | ( [+-]? ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | ( 0? [Bb] )? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | [01]* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | ( _ [01]+ )* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | //x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | # Get a "clean" version of the string, i.e., non-emtpy and with no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | # underscores or invalid characters. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | my $sign = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | my $chrs = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | $chrs =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | ▶ | $chrs = '0' unless CORE::length $chrs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | return $upgrade -> from_bin($sign . $chrs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | if length($chrs) > $MAX_BIN_LEN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | $$self = oct('0b' . $chrs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | ▶ | $$self = -$$self if $sign eq '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | # For consistency with from_hex() and from_oct(), we return NaN when the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | # input is invalid. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | return $self->bnan(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | # binc/bdec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 3 | ▶ | sub binc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binc: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | # increment by one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 3 | my ($up, $x, $y, @r) = _upgrade_1(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 3 | ▶ | return $x->binc(@r) if $up; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 3 | $$x++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 3 | ▶ | return $upgrade->new($$x) if abs($$x) > $MAX_ADD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 3 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 3 | ▶ | sub bdec { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bdec: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | # decrement by one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 3 | my ($up, $x, $y, @r) = _upgrade_1(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 3 | ▶ | return $x->bdec(@r) if $up; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 3 | $$x--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 3 | ▶ | return $upgrade->new($$x) if abs($$x) > $MAX_ADD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 3 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | # shifting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 26 | ▶ | sub brsft { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
brsft: called CC=11 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | # shift right | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 26 | my ($class, $x, $y, $b, @r) = objectify(2, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 26 | ▶ | $x = $class->new($x) unless ref($x); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 26 | ▶ | $y = $class->new($y) unless ref($y); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 26 | ▶ | $b = $$b if ref $b && $b->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $b and $b->isa($class)
MC/DC0%0/2
ref $b and $b->isa($class)
ref $b
$b->isa($class)
Truth table33%1/3
A and B
A= ref $bB= $b->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 26 | ▶ | if (!$x->isa($class)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | ▶ | $y = $upgrade->new($$y) if $y->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | return $x->brsft($y, $b, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 26 | ▶ | return $upgrade->new($$x)->brsft($y, $b, @r) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | unless $y->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 26 | ▶ | $b = 2 if !defined $b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | # can't do this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 26 | ▶ | return $upgrade->new($$x)->brsft($upgrade->new($$y), $b, @r) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$b != 2 or $$y < 0
MC/DC50%1/2
$b != 2 or $$y < 0
$b != 2
$$y < 0
Truth table66%2/3
A or B
A= $b != 2B= $$y < 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | if $b != 2 || $$y < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 6 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 18 | $$x >>= $$y; # only base 2 for now | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 18 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 12 | ▶ | sub blsft { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
blsft: called CC=9 SCAR=22.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | # shift left | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 12 | my ($class, $x, $y, $b, @r) = objectify(2, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 12 | ▶ | $x = $class->new($x) unless ref($x); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 12 | ▶ | $y = $class->new($x) unless ref($y); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 12 | ▶ | return $x->blsft($upgrade->new($$y), $b, @r) unless $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 12 | ▶ | return $upgrade->new($$x)->blsft($y, $b, @r) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | unless $y->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | # overflow: can't do this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 12 | ▶ | return $upgrade->new($$x)->blsft($upgrade->new($$y), $b, @r) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | if $$y > 31; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 12 | ▶ | $b = 2 if !defined $b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | # can't do this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 12 | ▶ | return $upgrade->new($$x)->blsft($upgrade->new($$y), $b, @r) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$b != 2 or $$y < 0
MC/DC50%1/2
$b != 2 or $$y < 0
$b != 2
$$y < 0
Truth table66%2/3
A or B
A= $b != 2B= $$y < 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | if $b != 2 || $$y < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 6 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 6 | $$x <<= $$y; # only base 2 for now | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 6 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | # Bitwise methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | # Bitwise left shift. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 5 | ▶ | sub bblsft { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bblsft: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 5 | ▶ | my ($class, $x, $y, @r) = ref($_[0]) ? (ref($_[0]), @_) : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | # For now, upgrade, but we should handle simple cases here. Fixme! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 5 | $upgrade -> bblsft($x, $y, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | # Bitwise right shift. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 2 | ▶ | sub bbrsft { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bbrsft: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 2 | ▶ | my ($class, $x, $y, @r) = ref($_[0]) ? (ref($_[0]), @_) : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | # For now, upgrade, but we should handle simple cases here. Fixme! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 2 | $upgrade -> bbrsft($x, $y, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 15 | ▶ | sub band { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
band: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | # AND two objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 15 | ▶ | my ($class, $x, $y, @r) = ref($_[0]) && ref($_[0]) eq ref($_[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $_[0] and ref $_[0] eq ref $_[1]
MC/DC50%1/2
ref $_[0] and ref $_[0] eq ref $_[1]
ref $_[0]
ref $_[0] eq ref $_[1]
Truth table66%2/3
A and B
A= ref $_[0]B= ref $_[0] eq ref $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | ? (ref($_[0]), @_) : objectify(2, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 15 | ▶ | return $upgrade -> band($x, $y, @r) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$x->isa($class) and $y->isa($class)
MC/DC50%1/2
$x->isa($class) and $y->isa($class)
$x->isa($class)
$y->isa($class)
Truth table66%2/3
A and B
A= $x->isa($class)B= $y->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | unless $x -> isa($class) && $y -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 6 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 14 | $$x = ($$x+0) & ($$y+0); # +0 to avoid string-context | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 14 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 22 | ▶ | sub bxor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bxor: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | # XOR two objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 22 | ▶ | my ($class, $x, $y, @r) = ref($_[0]) && ref($_[0]) eq ref($_[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $_[0] and ref $_[0] eq ref $_[1]
MC/DC50%1/2
ref $_[0] and ref $_[0] eq ref $_[1]
ref $_[0]
ref $_[0] eq ref $_[1]
Truth table66%2/3
A and B
A= ref $_[0]B= ref $_[0] eq ref $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | ? (ref($_[0]), @_) : objectify(2, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 22 | ▶ | return $upgrade -> bxor($x, $y, @r) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$x->isa($class) and $y->isa($class)
MC/DC50%1/2
$x->isa($class) and $y->isa($class)
$x->isa($class)
$y->isa($class)
Truth table66%2/3
A and B
A= $x->isa($class)B= $y->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | unless $x -> isa($class) && $y -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 6 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 16 | $$x = ($$x+0) ^ ($$y+0); # +0 to avoid string-context | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 16 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 21 | ▶ | sub bior { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bior: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | # OR two objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 21 | ▶ | my ($class, $x, $y, @r) = ref($_[0]) && ref($_[0]) eq ref($_[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $_[0] and ref $_[0] eq ref $_[1]
MC/DC50%1/2
ref $_[0] and ref $_[0] eq ref $_[1]
ref $_[0]
ref $_[0] eq ref $_[1]
Truth table66%2/3
A and B
A= ref $_[0]B= ref $_[0] eq ref $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | ? (ref($_[0]), @_) : objectify(2, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 21 | ▶ | return $upgrade -> bior($x, $y, @r) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$x->isa($class) and $y->isa($class)
MC/DC50%1/2
$x->isa($class) and $y->isa($class)
$x->isa($class)
$y->isa($class)
Truth table66%2/3
A and B
A= $x->isa($class)B= $y->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | unless $x -> isa($class) && $y -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 6 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 15 | $$x = ($$x+0) | ($$y+0); # +0 to avoid string-context | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 15 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | # mul/add/div etc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 60 | ▶ | sub badd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
badd: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | # add two objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 60 | my ($up, $x, $y, @r) = _upgrade_2(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 60 | ▶ | return $x->badd($y, @r) if $up; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 46 | $$x = $$x + $$y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 46 | ▶ | return $upgrade->new($$x) if abs($$x) > $MAX_ADD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 46 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 65 | ▶ | sub bsub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bsub: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | # subtract two objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 65 | my ($up, $x, $y, @r) = _upgrade_2(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 65 | ▶ | return $x->bsub($y, @r) if $up; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 64 | $$x = $$x - $$y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 64 | ▶ | return $upgrade->new($$x) if abs($$x) > $MAX_ADD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 64 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 37 | ▶ | sub bmul { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bmul: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | # multiply two objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 37 | my ($up, $x, $y, @r) = _upgrade_2_mul(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 37 | ▶ | return $x->bmul($y, @r) if $up; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 34 | $$x = $$x * $$y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 34 | ▶ | $$x = 0 if $$x eq '-0'; # for some Perls leave '-0' here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | #return $upgrade->new($$x) if abs($$x) > $MAX_ADD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 34 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 63 | ▶ | sub bmod { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bmod: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | # remainder of div | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 63 | my ($up, $x, $y, @r) = _upgrade_2(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 63 | ▶ | return $x->bmod($y, @r) if $up; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 57 | ▶ | return $upgrade->new($$x)->bmod($y, @r) if $$y == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 54 | $$x = $$x % $$y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 54 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 108 | ▶ | sub bdiv { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bdiv: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | # divide two objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 108 | my ($up, $x, $y, @r) = _upgrade_2(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 108 | ▶ | return $x->bdiv($y, @r) if $up; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 96 | ▶ | return $upgrade->new($$x)->bdiv($$y, @r) if $$y == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | # need to give Math::BigInt a chance to upgrade further | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 90 | ▶ | return $upgrade->new($$x)->bdiv($$y, @r) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | if defined $Math::BigInt::upgrade; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 90 | my ($quo, $rem); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 90 | $rem = \($$x % $$y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 90 | $quo = int($$x / $$y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 90 | ▶ | $quo-- if $$rem != 0 && ($$x <=> 0) != ($$y <=> 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$$rem != 0 and ($$x <=> 0) != ($$y <=> 0)
MC/DC100%2/2
$$rem != 0 and ($$x <=> 0) != ($$y <=> 0)
$$rem != 0
($$x <=> 0) != ($$y <=> 0)
Truth table100%3/3
A and B
A= $$rem != 0B= ($$x <=> 0) != ($$y <=> 0)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 90 | $$x = $quo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 90 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 42 | bless $rem, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 42 | return $x, $rem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 48 | return $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 102 | ▶ | sub btdiv { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
btdiv: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | # divide two objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 102 | my ($up, $x, $y, @r) = _upgrade_2(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 102 | ▶ | return $x->btdiv($y, @r) if $up; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 90 | ▶ | return $upgrade->new($$x)->btdiv($$y, @r) if $$y == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | # need to give Math::BigInt a chance to upgrade further | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 84 | ▶ | return $upgrade->new($$x)->btdiv($$y, @r) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | if defined $Math::BigInt::upgrade; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 84 | my ($quo, $rem); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 84 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 42 | $rem = \($$x % $$y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 42 | ▶ | $$rem -= $$y if $$rem != 0 && ($$x <=> 0) != ($$y <=> 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$$rem != 0 and ($$x <=> 0) != ($$y <=> 0)
MC/DC100%2/2
$$rem != 0 and ($$x <=> 0) != ($$y <=> 0)
$$rem != 0
($$x <=> 0) != ($$y <=> 0)
Truth table100%3/3
A and B
A= $$rem != 0B= ($$x <=> 0) != ($$y <=> 0)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 42 | bless $rem, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 84 | $quo = int($$x / $$y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 84 | $$x = $quo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 84 | ▶ | return $x, $rem if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 42 | return $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | # is_foo methods (the rest is inherited) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 3 | ▶ | sub is_int { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_int: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | # return true if arg (BLite or num_str) is an integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 3 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 3 | ▶ | return 1 if $x->isa($class); # Lite objects are always int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | $x->is_int(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 7 | ▶ | sub is_inf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_inf: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | # return true if arg (BLite or num_str) is an infinity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 7 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 7 | ▶ | return 0 if $x->isa($class); # Lite objects are never inf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | $x->is_inf(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 4 | ▶ | sub is_nan { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_nan: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | # return true if arg (BLite or num_str) is an NaN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 4 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 4 | ▶ | return 0 if $x->isa($class); # Lite objects are never NaN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | $x->is_nan(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 11 | ▶ | sub is_zero { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_zero: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | # return true if arg (BLite or num_str) is zero | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 11 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 11 | ▶ | return ($$x == 0) <=> 0 if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | $x->is_zero(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 3 | ▶ | sub is_positive { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_positive: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | # return true if arg (BLite or num_str) is positive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 3 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 3 | ▶ | return ($$x > 0) <=> 0 if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | $x->is_positive(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 3 | ▶ | sub is_negative { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_negative: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | # return true if arg (BLite or num_str) is negative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 3 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 3 | ▶ | return ($$x < 0) <=> 0 if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | $x->is_positive(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 9 | ▶ | sub is_one { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_one: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | # return true if arg (BLite or num_str) is one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 9 | ▶ | my ($class, $x, $s) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 9 | my $one = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 9 | ▶ | $one = -1 if ($s || '+') eq '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$s || '+'
MC/DC100%1/1
$s || '+'
$s
Truth table100%2/2
A
A= $s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 9 | ▶ | return ($$x == $one) <=> 0 if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 0 | $x->is_one(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 10 | ▶ | sub is_odd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_odd: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | # return true if arg (BLite or num_str) is odd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 10 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 10 | ▶ | return $x->is_odd() unless $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 10 | ▶ | $$x & 1 == 1 ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 10 | ▶ | sub is_even { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_even: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | # return true if arg (BLite or num_str) is even | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 10 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 10 | ▶ | return $x->is_even() unless $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 10 | ▶ | $$x & 1 == 1 ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | # parts() and friends | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 0 | ▶ | sub sign { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sign: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 0 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 0 | ▶ | $$x >= 0 ? '+' : '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 6 | ▶ | sub parts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parts: called CC=5 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 6 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 6 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table33%1/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 6 | ▶ | if ($$x =~ / ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | [+-]? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | (?: 0 | [1-9] (?: \d* [1-9] )? ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | ( 0* ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | /x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 6 | my $mant = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 6 | my $expo = CORE::length($2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 6 | return $class -> new($mant), $class -> new($expo); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 0 | die "Internal error: ", (caller(0))[3], "() couldn't handle", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | " the value '", $$x, "', which is likely a bug"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | 6 | ▶ | sub exponent { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exponent: called CC=5 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 6 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 6 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table33%1/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 6 | my $expo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 6 | ▶ | if ($$x =~ / (?: ^ 0 | [1-9] ) ( 0* ) $/x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 6 | $expo = CORE::length($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 6 | return $class -> new($expo); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | 0 | die "Internal error: ", (caller(0))[3], "() couldn't handle", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | " the value '", $$x, "', which is likely a bug"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 5 | ▶ | sub mantissa { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mantissa: called CC=5 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 5 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | 5 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table33%1/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 5 | ▶ | if ($$x =~ / ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | [+-]? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | (?: 0 | [1-9] (?: \d* [1-9] )? ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | /x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 5 | return $class -> new($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 0 | die "Internal error: ", (caller(0))[3], "() couldn't handle", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | " the value '", $$x, "', which is likely a bug"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | ▶ | sub sparts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sparts: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 0 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table0%0/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | ▶ | if ($$x =~ / ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | [+-]? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | (?: 0 | [1-9] (?: \d* [1-9] )? ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | ( 0* ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | /x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 0 | my $mant = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | 0 | my $expo = CORE::length($2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | 0 | ▶ | return $class -> new($mant) unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | return $class -> new($mant), $class -> new($expo); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 0 | die "Internal error: ", (caller(0))[3], "() couldn't handle", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | " the value '", $$x, "', which is likely a bug"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | ▶ | sub nparts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nparts: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 0 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table0%0/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 0 | my ($mant, $expo); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 0 | ▶ | if ($$x =~ / ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | ( [+-]? \d ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | ( 0* ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | /x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | $mant = $class -> new($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | $expo = $class -> new(CORE::length($2)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | } elsif ($$x =~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | / ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | ( [+-]? [1-9] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | ( \d+ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | /x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 0 | $mant = $upgrade -> new($1 . "." . $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 0 | $expo = $class -> new(CORE::length($2)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | 0 | die "Internal error: ", (caller(0))[3], "() couldn't handle", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | " the value '", $$x, "', which is likely a bug"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | ▶ | return $mant unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | return $mant, $expo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | 0 | ▶ | sub eparts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eparts: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table0%0/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | # Finite number. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | my ($mant, $expo) = $x -> sparts(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | 0 | ▶ | if ($mant -> bcmp(0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | my $ndigmant = $mant -> length(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | 0 | $expo = $expo -> badd($ndigmant); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | # $c is the number of digits that will be in the integer part of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | # final mantissa. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | 0 | my $c = $expo -> copy() -> bdec() -> bmod(3) -> binc(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | 0 | $expo = $expo -> bsub($c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | ▶ | if ($ndigmant > $c) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 0 | ▶ | return $upgrade -> eparts($x) if defined $upgrade; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | $mant = $mant -> bnan(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | ▶ | return $mant unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 0 | return ($mant, $expo); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | $mant = $mant -> blsft($c - $ndigmant, 10); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 0 | ▶ | return $mant unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | 0 | return ($mant, $expo); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 0 | ▶ | sub dparts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dparts: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 0 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | 0 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table0%0/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 0 | my $int = $x -> copy(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | 0 | my $frc = $class -> bzero(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 0 | ▶ | return $int unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 0 | return $int, $frc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 0 | ▶ | sub fparts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fparts: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | 0 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 0 | ▶ | return $upgrade -> exponent($x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
MC/DC0%0/2
defined $Math::BigInt::Lite::upgrade and not $x->isa($class)
defined $Math::BigInt::Lite::upgrade
not $x->isa($class)
Truth table0%0/3
A and not(B)
A= defined $Math::BigInt::Lite::upgradeB= not $x->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | if defined($upgrade) && !$x -> isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 0 | my $num = $x -> copy(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 0 | my $den = $class -> bone(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 0 | ▶ | return $num unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 0 | return $num, $den; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 22 | ▶ | sub digit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
digit: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | 22 | ▶ | my ($class, $x, $n) = ref($_[0]) ? (ref($_[0]), @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 22 | ▶ | return $x->digit($n) unless $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 22 | ▶ | $n = 0 if !defined $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 22 | my $len = length("$$x"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | 22 | ▶ | $n = $len+$n if $n < 0; # -1 last, -2 second-to-last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | 22 | $n = abs($n); # if negative was too big | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 22 | $len--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | 22 | ▶ | $n = $len if $n > $len; # n to big? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 22 | substr($$x, -$n-1, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 6 | ▶ | sub length { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
length: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 6 | ▶ | my ($class, $x) = ref($_[0]) ? (ref($_[0]), $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | 6 | ▶ | return $x->length() unless $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | 6 | my $l = length($$x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 6 | ▶ | $l-- if $$x < 0; # -123 => 123 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | 6 | $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | # sign based methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 25 | ▶ | sub babs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
babs: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 25 | ▶ | my ($class, $x) = ref($_[0]) ? (undef, $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 25 | $$x = abs($$x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 25 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | 29 | ▶ | sub bneg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bneg: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 29 | ▶ | my ($class, $x) = ref($_[0]) ? (undef, $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | 29 | ▶ | $$x = -$$x if $$x != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | 29 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | 5 | ▶ | sub bnot { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bnot: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 5 | ▶ | my ($class, $x) = ref($_[0]) ? (undef, $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | 5 | $$x = -$$x - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 5 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | # special calc routines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | 5 | ▶ | sub bceil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bceil: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | 5 | ▶ | my ($class, $x) = ref($_[0]) ? (undef, $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | 5 | $x; # no-op | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | 5 | ▶ | sub bfloor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bfloor: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 5 | ▶ | my ($class, $x) = ref($_[0]) ? (undef, $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | 5 | $x; # no-op | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | 5 | ▶ | sub bint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bint: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 5 | ▶ | my ($class, $x) = ref($_[0]) ? (undef, $_[0]) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | 5 | $x; # no-op | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | 17 | ▶ | sub bfac { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bfac: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | 17 | ▶ | my ($self, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | ($class, $class->new($_[0]), $_[1], $_[2], $_[3], $_[4]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 17 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 17 | $upgrade->bfac($x, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | 15 | ▶ | sub bdfac { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bdfac: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 15 | ▶ | my ($self, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | ($class, $class->new($_[0]), $_[1], $_[2], $_[3], $_[4]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | 15 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 15 | $upgrade->bdfac($x, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | 16 | ▶ | sub btfac { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
btfac: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | 16 | ▶ | my ($self, $x, @r) = ref($_[0]) ? (ref($_[0]), @_) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | ($class, $class->new($_[0]), $_[1], $_[2], $_[3], $_[4]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | 16 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | 16 | $upgrade->btfac($x, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | 75 | ▶ | sub bmfac { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bmfac: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 75 | my ($class, $x, $k, @r) = objectify(2, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | 75 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | 75 | $upgrade->bmfac($x, $k, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | 97 | ▶ | sub bpow { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bpow: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | 97 | my ($class, $x, $y, @r) = objectify(2, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | 97 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 97 | ▶ | $y = $upgrade->new($$y) if $y->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 97 | $x->bpow($y, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | 38 | ▶ | sub blog { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
blog: called CC=8 SCAR=22.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | 38 | my ($class, $x, $base, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | # Don't objectify the base, since an undefined base, as in $x->blog() or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | # $x->blog(undef) signals that the base is Euler's number. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | 38 | ▶ | if (!ref($_[0]) && $_[0] =~ /^[A-Za-z]|::/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not ref $_[0] and $_[0] =~ /^[A-Za-z]|::/
MC/DC0%0/2
not ref $_[0] and $_[0] =~ /^[A-Za-z]|::/
not ref $_[0]
$_[0] =~ /^[A-Za-z]|::/
Truth table33%1/3
not(A) and B
A= not ref $_[0]B= $_[0] =~ /^[A-Za-z]|::/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | # E.g., Math::BigInt::Lite->blog(256, 2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | 0 | ▶ | ($class, $x, $base, @r) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | defined $_[2] ? objectify(2, @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | # E.g., Math::BigInt::Lite::blog(256, 2) or $x->blog(2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | 38 | ▶ | ($class, $x, $base, @r) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | defined $_[1] ? objectify(2, @_) : objectify(1, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | 38 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | 38 | ▶ | $base = $upgrade->new($$base) if defined $base && $base->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $base and $base->isa($class)
MC/DC100%2/2
defined $base and $base->isa($class)
defined $base
$base->isa($class)
Truth table100%3/3
A and B
A= defined $baseB= $base->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | 38 | $x->blog($base, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | 2 | ▶ | sub bexp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bexp: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 2 | my ($class, $x, @r) = objectify(1, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 2 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 2 | $x->bexp(@r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | 20 | ▶ | sub batan2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
batan2: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | 20 | my ($class, $x, $y, @r) = objectify(2, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 20 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | 20 | $x->batan2($y, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | 4880 | ▶ | sub bnok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bnok: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 4880 | my ($class, $x, $y, @r) = objectify(2, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | 4880 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 4880 | ▶ | $y = $upgrade->new($$y) if $y->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | 4880 | $x->bnok($y, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 31 | ▶ | sub broot { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
broot: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | 31 | my ($class, $x, $base, @r) = objectify(2, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 31 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | 31 | ▶ | $base = $upgrade->new($$base) if defined $base && $base->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $base and $base->isa($class)
MC/DC50%1/2
defined $base and $base->isa($class)
defined $base
$base->isa($class)
Truth table66%2/3
A and B
A= defined $baseB= $base->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | 31 | $x->broot($base, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | 27 | ▶ | sub bmuladd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bmuladd: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | 27 | my ($class, $x, $y, $z, @r) = objectify(2, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | 27 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | 27 | ▶ | $y = $upgrade->new($$y) if defined $y && $y->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $y and $y->isa($class)
MC/DC50%1/2
defined $y and $y->isa($class)
defined $y
$y->isa($class)
Truth table66%2/3
A and B
A= defined $yB= $y->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | 27 | ▶ | $z = $upgrade->new($$z) if defined $z && $z->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $z and $z->isa($class)
MC/DC50%1/2
defined $z and $z->isa($class)
defined $z
$z->isa($class)
Truth table66%2/3
A and B
A= defined $zB= $z->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | 27 | $x->bmuladd($y, $z, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | 160 | ▶ | sub bmodpow { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bmodpow: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | 160 | my ($class, $x, $y, @r) = objectify(2, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 160 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | 160 | ▶ | $y = $upgrade->new($$y) if defined $y && $y->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $y and $y->isa($class)
MC/DC50%1/2
defined $y and $y->isa($class)
defined $y
$y->isa($class)
Truth table66%2/3
A and B
A= defined $yB= $y->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | 160 | $x->bmodpow($y, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 29 | ▶ | sub bmodinv { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bmodinv: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 29 | my ($class, $x, $y, @r) = objectify(2, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | 29 | ▶ | $x = $upgrade->new($$x) if $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | 29 | ▶ | $y = $upgrade->new($$y) if defined $y && $y->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $y and $y->isa($class)
MC/DC50%1/2
defined $y and $y->isa($class)
defined $y
$y->isa($class)
Truth table66%2/3
A and B
A= defined $yB= $y->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | 29 | $x->bmodinv($y, @r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | 17 | ▶ | sub bsqrt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bsqrt: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 17 | ▶ | my ($class, $x, @r) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | ref($_[0]) ? (ref($_[0]), @_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | : ($class, $class->new($_[0]), $_[1], $_[2], $_[3]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | 17 | ▶ | return $x->bsqrt(@r) unless $x->isa($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | 17 | ▶ | return $upgrade->new($$x)->bsqrt() if $$x < 0; # NaN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 15 | my $s = sqrt($$x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | # If MBI's upgrade is defined, and result is non-integer, we need to hand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | # up. If upgrade is undef, result would be the same, anyway | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | 15 | ▶ | if (int($s) != $s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | 7 | return $upgrade->new($$x)->bsqrt(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | 8 | $$x = $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | 8 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | 3 | ▶ | sub bpi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bpi: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | 3 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 3 | $class -> new("3"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 5 | ▶ | sub to_bin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_bin: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | 5 | $upgrade -> new($$self) -> to_bin(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | 5 | ▶ | sub to_oct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_oct: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | 5 | $upgrade -> new($$self) -> to_oct(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | 5 | ▶ | sub to_hex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_hex: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | 5 | $upgrade -> new($$self) -> to_hex(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | 6 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=7 SCAR=33.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | 6 | my @a = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | 6 | my $l = scalar @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 6 | my $j = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | 6 | my $lib = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | 6 | ▶ | for (my $i = 0; $i < $l ; $i++, $j++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | 0 | ▶ | if ($_[$i] eq ':constant') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | # this causes overlord er load to step in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | 0 | ▶ | overload::constant integer => sub { $self->new(shift) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | 0 | splice @a, $j, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | $j --; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | } elsif ($_[$i] eq 'upgrade') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | # this causes upgrading | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | 0 | $upgrade = $_[$i+1]; # or undef to disable | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 0 | my $s = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | 0 | ▶ | $s = 1 if @a-$j < 2; # no "can not modify non-existant..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | 0 | splice @a, $j, $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | 0 | $j -= $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | } elsif ($_[$i] eq 'lib') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | 0 | $lib = $_[$i+1]; # or undef to disable | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 0 | my $s = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | 0 | ▶ | $s = 1 if @a-$j < 2; # no "can not modify non-existant..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | 0 | splice @a, $j, $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | 0 | $j -= $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | # any non :constant stuff is handled by our parent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | # even if @_ is empty, to give it a chance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 6 | $self->SUPER::import(@a); # need it for subclasses | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | 6 | $self->export_to_level(1, $self, @a); # need it for MBF | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||