| 1 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | package MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::StringNumericLiteral::NativeNumberSemantics; | ||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use Data::Float qw/have_signed_zero have_infinite have_nan/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Math::BigFloat; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Scalar::Util::Numeric qw/isinf isnan/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 6 | our $POS_ZERO = have_signed_zero() ? Data::Float::pos_zero() : 0; | |||||||||||||||||||||||||||||||
| 11 | 6 | our $NEG_ZERO = have_signed_zero() ? Data::Float::neg_zero() : 0; | |||||||||||||||||||||||||||||||
| 12 | 6 | our $POS_INF = have_infinite() ? Data::Float::pos_infinity() : Math::BigFloat->binf(); | |||||||||||||||||||||||||||||||
| 13 | 6 | our $NEG_INF = have_infinite() ? Data::Float::neg_infinity() : Math::BigFloat->binf('-'); | |||||||||||||||||||||||||||||||
| 14 | 6 | our $POS_ONE = +1; | |||||||||||||||||||||||||||||||
| 15 | 6 | our $NEG_ONE = -1; | |||||||||||||||||||||||||||||||
| 16 | 6 | our $NAN = have_nan() ? Data::Float::nan() : Math::BigFloat->bnan(); | |||||||||||||||||||||||||||||||
| 17 | 6 | our $UNDEF = undef; | |||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | # ABSTRACT: ECMAScript 262, Edition 5, lexical string numeric grammar default semantics package, using native perl representations | ||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 6 | our $VERSION = '0.020'; # VERSION | |||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 26 | 0 | my ($class, %opts) = @_; | |||||||||||||||||||||||||||||||
| 27 | my $self = {_number => $opts{number} // 0, | ||||||||||||||||||||||||||||||||
| 28 | _length => $opts{length} // 0, | ||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | _decimal => $opts{decimal } // 0}; | ||||||||||||||||||||||||||||||
|
Condition0%0/6
$opts{"number"} // 0
$opts{"length"} // 0
$opts{"decimal"} // 0
MC/DC0%0/1
$opts{"number"} // 0
$opts{"number"}
MC/DC0%0/1
$opts{"length"} // 0
$opts{"length"}
MC/DC0%0/1
$opts{"decimal"} // 0
$opts{"decimal"}
Truth table0%0/2
A
A= $opts{"number"}
Truth table0%0/2
A
A= $opts{"length"}
Truth table0%0/2
A
A= $opts{"decimal"}
| |||||||||||||||||||||||||||||||||
| 30 | 0 | bless($self, $class); | |||||||||||||||||||||||||||||||
| 31 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub clone_init { | ||||||||||||||||||||||||||||||
|
Subroutine
clone_init: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 36 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 37 | 0 | return (ref $self)->new(); | |||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub clone { | ||||||||||||||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 42 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 43 | 0 | return (ref $self)->new(number => $self->{_number}, length => $self->{_length}, decimal => $self->{_decimal}); | |||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub decimalOn { | ||||||||||||||||||||||||||||||
|
Subroutine
decimalOn: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 48 | 0 | $_[0]->{_decimal} = 1; | |||||||||||||||||||||||||||||||
| 49 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub mul { | ||||||||||||||||||||||||||||||
|
Subroutine
mul: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 54 | 0 | $_[0]->{_number} *= $_[1]->{_number}; | |||||||||||||||||||||||||||||||
| 55 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub div { | ||||||||||||||||||||||||||||||
|
Subroutine
div: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 60 | 0 | $_[0]->{_number} /= $_[1]->{_number}; | |||||||||||||||||||||||||||||||
| 61 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub mod { | ||||||||||||||||||||||||||||||
|
Subroutine
mod: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 66 | 0 | $_[0]->{_number} %= $_[1]->{_number}; | |||||||||||||||||||||||||||||||
| 67 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub nan { | ||||||||||||||||||||||||||||||
|
Subroutine
nan: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 72 | 0 | $_[0]->{_number} = $NAN; | |||||||||||||||||||||||||||||||
| 73 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub pos_one { | ||||||||||||||||||||||||||||||
|
Subroutine
pos_one: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 78 | 0 | $_[0]->{_number} = $POS_ONE; | |||||||||||||||||||||||||||||||
| 79 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub neg_one { | ||||||||||||||||||||||||||||||
|
Subroutine
neg_one: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 84 | 0 | $_[0]->{_number} = $NEG_ONE; | |||||||||||||||||||||||||||||||
| 85 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub pos_zero { | ||||||||||||||||||||||||||||||
|
Subroutine
pos_zero: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 90 | 0 | $_[0]->{_number} = $POS_ZERO; | |||||||||||||||||||||||||||||||
| 91 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub neg_zero { | ||||||||||||||||||||||||||||||
|
Subroutine
neg_zero: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 96 | 0 | $_[0]->{_number} = $NEG_ZERO; | |||||||||||||||||||||||||||||||
| 97 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | sub pos_inf { | ||||||||||||||||||||||||||||||
|
Subroutine
pos_inf: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 102 | 0 | $_[0]->{_number} = $POS_INF; | |||||||||||||||||||||||||||||||
| 103 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub neg_inf { | ||||||||||||||||||||||||||||||
|
Subroutine
neg_inf: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 108 | 0 | $_[0]->{_number} = $NEG_INF; | |||||||||||||||||||||||||||||||
| 109 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub pow { | ||||||||||||||||||||||||||||||
|
Subroutine
pow: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 114 | 0 | $_[0]->{_number} **= $_[1]->{_number}; | |||||||||||||||||||||||||||||||
| 115 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub and { | ||||||||||||||||||||||||||||||
|
Subroutine
and: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 120 | 0 | $_[0]->{_number} &= $_[1]->{_number}; | |||||||||||||||||||||||||||||||
| 121 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub or { | ||||||||||||||||||||||||||||||
|
Subroutine
or: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 126 | 0 | $_[0]->{_number} |= $_[1]->{_number}; | |||||||||||||||||||||||||||||||
| 127 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub xor { | ||||||||||||||||||||||||||||||
|
Subroutine
xor: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 132 | 0 | $_[0]->{_number} ^= $_[1]->{_number}; | |||||||||||||||||||||||||||||||
| 133 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub not { | ||||||||||||||||||||||||||||||
|
Subroutine
not: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 138 | 0 | $_[0]->{_number} = ~$_[0]->{_number}; | |||||||||||||||||||||||||||||||
| 139 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub sqrt { | ||||||||||||||||||||||||||||||
|
Subroutine
sqrt: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 144 | 0 | my $x = eval {sqrt($_[0]->{_number})}; | |||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 146 | 0 | return $_[0]->nan(); | |||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||
| 148 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub left_shift { | ||||||||||||||||||||||||||||||
|
Subroutine
left_shift: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 153 | 0 | $_[0]->{_number} <<= $_[1]->{_number}; | |||||||||||||||||||||||||||||||
| 154 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub right_shift { | ||||||||||||||||||||||||||||||
|
Subroutine
right_shift: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 159 | 0 | $_[0]->{_number} >>= $_[1]->{_number}; | |||||||||||||||||||||||||||||||
| 160 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | sub inc { | ||||||||||||||||||||||||||||||
|
Subroutine
inc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 165 | 0 | $_[0]->{_number} += 1; | |||||||||||||||||||||||||||||||
| 166 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | sub dec { | ||||||||||||||||||||||||||||||
|
Subroutine
dec: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 171 | 0 | $_[0]->{_number} -= 1; | |||||||||||||||||||||||||||||||
| 172 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | sub int { | ||||||||||||||||||||||||||||||
|
Subroutine
int: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 177 | 0 | $_[0]->{_number} = CORE::int("$_[1]"); | |||||||||||||||||||||||||||||||
| 178 | 0 | $_[0]->{_length} = length("$_[1]"); | |||||||||||||||||||||||||||||||
| 179 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | sub hex { | ||||||||||||||||||||||||||||||
|
Subroutine
hex: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 184 | 0 | $_[0]->{_number} = CORE::hex("$_[1]"); | |||||||||||||||||||||||||||||||
| 185 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub neg { | ||||||||||||||||||||||||||||||
|
Subroutine
neg: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 190 | 0 | $_[0]->{_number} *= -1; | |||||||||||||||||||||||||||||||
| 191 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub abs { | ||||||||||||||||||||||||||||||
|
Subroutine
abs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 196 | 0 | $_[0]->{_number} = CORE::abs($_[0]->{_number}); | |||||||||||||||||||||||||||||||
| 197 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub new_from_sign { | ||||||||||||||||||||||||||||||
|
Subroutine
new_from_sign: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if ($_[0]->is_nan) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 203 | 0 | return $_[0]->clone_init->nan; | |||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||
| 205 | elsif ($_[0]->is_pos) { | ||||||||||||||||||||||||||||||||
| 206 | 0 | return $_[0]->clone_init->pos_one; | |||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||
| 208 | else { | ||||||||||||||||||||||||||||||||
| 209 | 0 | return $_[0]->clone_init->neg_one; | |||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub new_from_cmp { | ||||||||||||||||||||||||||||||
|
Subroutine
new_from_cmp: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if ($_[0]->is_nan || $_[1]->is_nan) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_[0]->is_nan or $_[1]->is_nan
MC/DC0%0/2
$_[0]->is_nan or $_[1]->is_nan
$_[0]->is_nan
$_[1]->is_nan
Truth table0%0/3
A or B
A= $_[0]->is_nanB= $_[1]->is_nan
| |||||||||||||||||||||||||||||||||
| 216 | 0 | return $_[0]->clone_init->nan; | |||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||
| 218 | else { | ||||||||||||||||||||||||||||||||
| 219 | 0 | my $tmp = $_[0]->clone->sub($_[1]); | |||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if ($tmp->is_zero) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 221 | 0 | return $_[0]->clone_init->pos_zero; | |||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||
| 223 | elsif ($tmp->is_neg) { | ||||||||||||||||||||||||||||||||
| 224 | 0 | return $_[0]->clone_init->neg_one; | |||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||
| 226 | else { | ||||||||||||||||||||||||||||||||
| 227 | 0 | return $_[0]->clone_init->pos_one; | |||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub add { | ||||||||||||||||||||||||||||||
|
Subroutine
add: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 234 | 0 | $_[0]->{_number} += $_[1]->{_number}; | |||||||||||||||||||||||||||||||
| 235 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | sub sub { | ||||||||||||||||||||||||||||||
|
Subroutine
sub: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 240 | 0 | $_[0]->{_number} -= $_[1]->{_number}; | |||||||||||||||||||||||||||||||
| 241 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub inc_length { | ||||||||||||||||||||||||||||||
|
Subroutine
inc_length: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 246 | 0 | ++$_[0]->{_length}; | |||||||||||||||||||||||||||||||
| 247 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | sub new_from_length { | ||||||||||||||||||||||||||||||
|
Subroutine
new_from_length: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 252 | 0 | return $_[0]->clone_init->int("$_[0]->{_length}"); | |||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | sub sign { | ||||||||||||||||||||||||||||||
|
Subroutine
sign: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | if ($_[0]->is_zero) { | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 258 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||
| 260 | elsif ($_[0]->is_pos) { | ||||||||||||||||||||||||||||||||
| 261 | 0 | return 1; | |||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||
| 263 | elsif ($_[0]->is_neg) { | ||||||||||||||||||||||||||||||||
| 264 | 0 | return -1; | |||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||
| 266 | else { | ||||||||||||||||||||||||||||||||
| 267 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | sub cmp { | ||||||||||||||||||||||||||||||
|
Subroutine
cmp: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 273 | 0 | return $_[0]->new_from_cmp($_[1])->sign; | |||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | sub host_number { | ||||||||||||||||||||||||||||||
|
Subroutine
host_number: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 278 | 0 | return $_[0]->{_number}; | |||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | sub host_value { | ||||||||||||||||||||||||||||||
|
Subroutine
host_value: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 283 | # | ||||||||||||||||||||||||||||||||
| 284 | # This is native implementation, i.e. we assume that the Math and/or CPUs under the hood | ||||||||||||||||||||||||||||||||
| 285 | # are already IEEE-754 compliant, including rounding. | ||||||||||||||||||||||||||||||||
| 286 | # | ||||||||||||||||||||||||||||||||
| 287 | # This mean that we return internal number as is. | ||||||||||||||||||||||||||||||||
| 288 | # | ||||||||||||||||||||||||||||||||
| 289 | 0 | return $_[0]->{_number}; | |||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | sub is_zero { | ||||||||||||||||||||||||||||||
|
Subroutine
is_zero: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | my $blessed = blessed($_[0]->{_number}) || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
builtin::blessed($_[0]{'_number'}) || ''
MC/DC0%0/1
builtin::blessed($_[0]{'_number'}) || ''
builtin::blessed($_[0]{'_number'})
Truth table0%0/2
A
A= builtin::blessed($_[0]{'_number'})
| |||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | if (! $blessed) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 296 | # | ||||||||||||||||||||||||||||||||
| 297 | # float_is_zero never fails | ||||||||||||||||||||||||||||||||
| 298 | # | ||||||||||||||||||||||||||||||||
| 299 | 0 | return Data::Float::float_is_zero($_[0]->{_number}); | |||||||||||||||||||||||||||||||
| 300 | } elsif ($_[0]->{_number}->can('is_zero')) { | ||||||||||||||||||||||||||||||||
| 301 | 0 | return $_[0]->{_number}->is_zero(); | |||||||||||||||||||||||||||||||
| 302 | } else { | ||||||||||||||||||||||||||||||||
| 303 | 0 | return $UNDEF; | |||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | sub is_pos_one { | ||||||||||||||||||||||||||||||
|
Subroutine
is_pos_one: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | my $blessed = blessed($_[0]->{_number}) || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
builtin::blessed($_[0]{'_number'}) || ''
MC/DC0%0/1
builtin::blessed($_[0]{'_number'}) || ''
builtin::blessed($_[0]{'_number'})
Truth table0%0/2
A
A= builtin::blessed($_[0]{'_number'})
| |||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | if (! $blessed) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | return ($_[0]->{_number} == $POS_ONE) ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 312 | } elsif ($_[0]->{_number}->can('is_one')) { | ||||||||||||||||||||||||||||||||
| 313 | 0 | return $_[0]->{_number}->is_one(); | |||||||||||||||||||||||||||||||
| 314 | } else { | ||||||||||||||||||||||||||||||||
| 315 | 0 | return $UNDEF; | |||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub is_neg_one { | ||||||||||||||||||||||||||||||
|
Subroutine
is_neg_one: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | my $blessed = blessed($_[0]->{_number}) || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
builtin::blessed($_[0]{'_number'}) || ''
MC/DC0%0/1
builtin::blessed($_[0]{'_number'}) || ''
builtin::blessed($_[0]{'_number'})
Truth table0%0/2
A
A= builtin::blessed($_[0]{'_number'})
| |||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | if (! $blessed) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | return ($_[0]->{_number} == $NEG_ONE) ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 324 | } elsif ($_[0]->{_number}->can('is_one')) { | ||||||||||||||||||||||||||||||||
| 325 | 0 | return $_[0]->{_number}->is_one('-'); | |||||||||||||||||||||||||||||||
| 326 | } else { | ||||||||||||||||||||||||||||||||
| 327 | 0 | return $UNDEF; | |||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | sub is_pos { | ||||||||||||||||||||||||||||||
|
Subroutine
is_pos: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | my $blessed = blessed($_[0]->{_number}) || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
builtin::blessed($_[0]{'_number'}) || ''
MC/DC0%0/1
builtin::blessed($_[0]{'_number'}) || ''
builtin::blessed($_[0]{'_number'})
Truth table0%0/2
A
A= builtin::blessed($_[0]{'_number'})
| |||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | if (! $blessed) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if ($_[0]->is_nan) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 336 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 337 | } else { | ||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | return (Data::Float::signbit($_[0]->{_number}) == 0) ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||
| 340 | } elsif ($_[0]->{_number}->can('is_pos')) { | ||||||||||||||||||||||||||||||||
| 341 | 0 | return $_[0]->{_number}->is_pos(); | |||||||||||||||||||||||||||||||
| 342 | } else { | ||||||||||||||||||||||||||||||||
| 343 | 0 | return $UNDEF; | |||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | sub is_neg { | ||||||||||||||||||||||||||||||
|
Subroutine
is_neg: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | my $blessed = blessed($_[0]->{_number}) || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
builtin::blessed($_[0]{'_number'}) || ''
MC/DC0%0/1
builtin::blessed($_[0]{'_number'}) || ''
builtin::blessed($_[0]{'_number'})
Truth table0%0/2
A
A= builtin::blessed($_[0]{'_number'})
| |||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | if (! $blessed) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if ($_[0]->is_nan) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 352 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 353 | } else { | ||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | return (Data::Float::signbit($_[0]->{_number}) == 0) ? 0 : 1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||
| 356 | } elsif ($_[0]->{_number}->can('is_neg')) { | ||||||||||||||||||||||||||||||||
| 357 | 0 | return $_[0]->{_number}->is_neg(); | |||||||||||||||||||||||||||||||
| 358 | } else { | ||||||||||||||||||||||||||||||||
| 359 | 0 | return $UNDEF; | |||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | sub is_inf { | ||||||||||||||||||||||||||||||
|
Subroutine
is_inf: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | my $blessed = blessed($_[0]->{_number}) || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
builtin::blessed($_[0]{'_number'}) || ''
MC/DC0%0/1
builtin::blessed($_[0]{'_number'}) || ''
builtin::blessed($_[0]{'_number'})
Truth table0%0/2
A
A= builtin::blessed($_[0]{'_number'})
| |||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | if (! $blessed) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 367 | # | ||||||||||||||||||||||||||||||||
| 368 | # isinf() never fails | ||||||||||||||||||||||||||||||||
| 369 | # | ||||||||||||||||||||||||||||||||
| 370 | 0 | return isinf($_[0]->{_number}); | |||||||||||||||||||||||||||||||
| 371 | } elsif ($_[0]->{_number}->can('is_inf')) { | ||||||||||||||||||||||||||||||||
| 372 | 0 | return $_[0]->{_number}->is_inf(); | |||||||||||||||||||||||||||||||
| 373 | } else { | ||||||||||||||||||||||||||||||||
| 374 | 0 | return $UNDEF; | |||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub is_nan { | ||||||||||||||||||||||||||||||
|
Subroutine
is_nan: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | my $blessed = blessed($_[0]->{_number}) || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
builtin::blessed($_[0]{'_number'}) || ''
MC/DC0%0/1
builtin::blessed($_[0]{'_number'}) || ''
builtin::blessed($_[0]{'_number'})
Truth table0%0/2
A
A= builtin::blessed($_[0]{'_number'})
| |||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | if (! $blessed) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 382 | # | ||||||||||||||||||||||||||||||||
| 383 | # isnan() never fails | ||||||||||||||||||||||||||||||||
| 384 | # | ||||||||||||||||||||||||||||||||
| 385 | 0 | return isnan($_[0]->{_number}); | |||||||||||||||||||||||||||||||
| 386 | } elsif ($_[0]->{_number}->can('is_nan')) { | ||||||||||||||||||||||||||||||||
| 387 | 0 | return $_[0]->{_number}->is_nan(); | |||||||||||||||||||||||||||||||
| 388 | } else { | ||||||||||||||||||||||||||||||||
| 389 | 0 | return $UNDEF; | |||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||
| 393 | 6 | 1; | |||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||
| 395 | __END__ | ||||||||||||||||||||||||||||||||