bignum.pm

filter: Statementstmt 80.2% 162 / 202 Branchbran 58.1% 50 / 86 Conditioncond 65.0% 13 / 20 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 87.8% 29 / 33 Podpod 100% 15 / 15 totaltotal 73.9% 269 / 364 CC 51 SCAR 23.2
CC
51
Cov
73%
_oct_core
23.5
import
18.1
_float_constant
17.8
CRAP 10.2
↑ Summary bigint.pm »
1 package bignum;
2  
3 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 15 ▶use Carp qw< carp croak >;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 15 our $VERSION = '0.67';
9  
10 15 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 our @ISA = qw( Exporter );
12 15 our @EXPORT_OK = qw( PI e bpi bexp hex oct );
13 15 our @EXPORT = qw( inf NaN );
14  
15 15 ▶use overload;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 # Defaults: When a constant is an integer, Inf or NaN, it is converted to an
18 # object of class $int_class. When a constant is a finite non-integer, it is
19 # converted to an object of class $float_class.
20  
21 15 my $int_class = 'Math::BigInt';
22 15 my $float_class = 'Math::BigFloat';
23  
24 ##############################################################################
25  
26 5 ▶sub accuracy {
Subroutine accuracy: called CC=1 SCAR=0.0
Pod documented
27 5 shift;
28 5 $int_class -> accuracy(@_);
29 5 $float_class -> accuracy(@_);
30 }
31  
32 5 ▶sub precision {
Subroutine precision: called CC=1 SCAR=0.0
Pod documented
33 5 shift;
34 5 $int_class -> precision(@_);
35 5 $float_class -> precision(@_);
36 }
37  
38 5 ▶sub round_mode {
Subroutine round_mode: called CC=1 SCAR=0.0
Pod documented
39 5 shift;
40 5 $int_class -> round_mode(@_);
41 5 $float_class -> round_mode(@_);
42 }
43  
44 0 ▶sub div_scale {
Subroutine div_scale: not called CC=1 SCAR=6.9
Pod documented
45 0 shift;
46 0 $int_class -> div_scale(@_);
47 0 $float_class -> div_scale(@_);
48 }
49  
50 5 ▶sub upgrade {
Subroutine upgrade: called CC=1 SCAR=0.0
Pod documented
51 5 shift;
52 5 $int_class -> upgrade(@_);
53 }
54  
55 4 ▶sub downgrade {
Subroutine downgrade: called CC=1 SCAR=0.0
Pod documented
56 4 shift;
57 4 $float_class -> downgrade(@_);
58 }
59  
60 0 ▶sub in_effect {
Subroutine in_effect: not called CC=2 SCAR=17.9
Pod documented
61 0 ▶ my $level = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
62 0 my $hinthash = (caller($level))[10];
63 0 $hinthash->{bignum};
64 }
65  
66 91 ▶sub _float_constant {
Subroutine _float_constant: called CC=11 SCAR=28.8
67 91 my $str = shift;
68  
69 # See if we can convert the input string to a string using a normalized form
70 # consisting of the significand as a signed integer, the character "e", and
71 # the exponent as a signed integer, e.g., "+0e+0", "+314e-2", and "-1e+3".
72  
73 91 my $nstr;
74  
75 91 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /^0(?:[Oo]|_*[0-7])/ and $nstr = "Math::BigInt"->oct_str_to_dec_flt_str($str) or $nstr = "Math::BigInt"->dec_str_to_dec_flt_str($str) or $str =~ /^0[Xx]/ and $nstr = "Math::BigInt"->hex_str_to_dec_flt_str($str) or $str =~ /^0[Bb]/ and $nstr = "Math::BigInt"->bin_str_to_dec_flt_str($str)) 91 0 91
Condition72%13/18
$str =~ /^0(?:[Oo]|_*[0-7])/ and $nstr = "Math::BigInt"->oct_str_to_dec_flt_str($str) or $nstr = "Math::BigInt"->dec_str_to_dec_flt_str($str) or $str =~ /^0[Xx]/ and $nstr = "Math::BigInt"->hex_str_to_dec_flt_str($str) or $str =~ /^0[Bb]/ and $nstr = "Math::BigInt"->bin_str_to_dec_flt_str($str)
l!l&&r!l&&!r
73180
$str =~ /^0(?:[Oo]|_*[0-7])/ and $nstr = "Math::BigInt"->oct_str_to_dec_flt_str($str) or $nstr = "Math::BigInt"->dec_str_to_dec_flt_str($str) or $str =~ /^0[Xx]/ and $nstr = "Math::BigInt"->hex_str_to_dec_flt_str($str)
l!l&&r!l&&!r
591418
$str =~ /^0(?:[Oo]|_*[0-7])/ and $nstr = "Math::BigInt"->oct_str_to_dec_flt_str($str) or $nstr = "Math::BigInt"->dec_str_to_dec_flt_str($str)
l!l&&r!l&&!r
362332
$str =~ /^0(?:[Oo]|_*[0-7])/ and $nstr = "Math::BigInt"->oct_str_to_dec_flt_str($str)
!ll&&!rl&&r
55036
$str =~ /^0[Xx]/ and $nstr = "Math::BigInt"->hex_str_to_dec_flt_str($str)
!ll&&!rl&&r
18014
$str =~ /^0[Bb]/ and $nstr = "Math::BigInt"->bin_str_to_dec_flt_str($str)
!ll&&!rl&&r
0018
MC/DC0%0/7
$str =~ /^0(?:[Oo]|_*[0-7])/ and $nstr = "Math::BigInt"->oct_str_to_dec_flt_str($str) or $nstr = "Math::BigInt"->dec_str_to_dec_flt_str($str) or $str =~ /^0[Xx]/ and $nstr = "Math::BigInt"->hex_str_to_dec_flt_str($str) or $str =~ /^0[Bb]/ and $nstr = "Math::BigInt"->bin_str_to_dec_flt_str($str)
$str =~ /^0(?:[Oo]|_*[0-7])/ $nstr = "Math::BigInt"->oct_str_to_dec_flt_str($str) $nstr = "Math::BigInt"->dec_str_to_dec_flt_str($str) $str =~ /^0[Xx]/ $nstr = "Math::BigInt"->hex_str_to_dec_flt_str($str) $str =~ /^0[Bb]/ $nstr = "Math::BigInt"->bin_str_to_dec_flt_str($str)
Truth table23%4/17
A and B or C or D and E or F and G
A= $str =~ /^0(?:[Oo]|_*[0-7])/B= $nstr = "Math::BigInt"->oct_str_to_dec_flt_str($str)C= $nstr = "Math::BigInt"->dec_str_to_dec_flt_str($str)D= $str =~ /^0[Xx]/E= $nstr = "Math::BigInt"->hex_str_to_dec_flt_str($str)F= $str =~ /^0[Bb]/G= $nstr = "Math::BigInt"->bin_str_to_dec_flt_str($str)
ABCDEFGresult
11XXXXX1
0X1XXXX1
101XXXX1
0X011XX1
10011XX1
0X00X111
0X010111
1000X111
10010111
0X00X0X0
0X00X100
0X0100X0
0X010100
1000X0X0
1000X100
100100X0
10010100
76 # See if it is an octal number. An octal number like '0377' is also
77 # accepted by the functions parsing decimal and hexadecimal numbers, so
78 # handle octal numbers before decimal and hexadecimal numbers.
79  
80 $str =~ /^0(?:[Oo]|_*[0-7])/ and
81 $nstr = Math::BigInt -> oct_str_to_dec_flt_str($str)
82  
83 or
84  
85 # See if it is decimal number.
86  
87 $nstr = Math::BigInt -> dec_str_to_dec_flt_str($str)
88  
89 or
90  
91 # See if it is a hexadecimal number. Every hexadecimal number has a
92 # prefix, but the functions parsing numbers don't require it, so check
93 # to see if it actually is a hexadecimal number.
94  
95 $str =~ /^0[Xx]/ and
96 $nstr = Math::BigInt -> hex_str_to_dec_flt_str($str)
97  
98 or
99  
100 # See if it is a binary numbers. Every binary number has a prefix, but
101 # the functions parsing numbers don't require it, so check to see if it
102 # actually is a binary number.
103  
104 $str =~ /^0[Bb]/ and
105 $nstr = Math::BigInt -> bin_str_to_dec_flt_str($str))
106 {
107 91 my $pos = index($nstr, 'e');
108 91 my $expo_sgn = substr($nstr, $pos + 1, 1);
109 91 my $sign = substr($nstr, 0, 1);
110 91 my $mant = substr($nstr, 1, $pos - 1);
111 91 my $mant_len = CORE::length($mant);
112 91 my $expo = substr($nstr, $pos + 2);
113  
114 # The number is a non-integer if and only if the exponent is negative.
115  
116 91 ▶ if ($expo_sgn eq '-') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expo_sgn eq '-') { } 41 50 91
117 41 return $float_class -> new($str);
118  
119 0 my $upgrade = $int_class -> upgrade();
120 0 ▶ return $upgrade -> new($nstr) if defined $upgrade;
Branch: 1 branch
BranchTrueFalseTotal
if defined $upgrade 0 0 0
121  
122 0 ▶ if ($mant_len <= $expo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mant_len <= $expo) { } 0 0 0
123 0 return $int_class -> bzero(); # underflow
124 } else {
125 0 $mant = substr $mant, 0, $mant_len - $expo; # truncate
126 0 return $int_class -> new($sign . $mant);
127 }
128 } else {
129 50 $mant .= "0" x $expo; # pad with zeros
130 50 return $int_class -> new($sign . $mant);
131 }
132 }
133  
134 # If we get here, there is a bug in the code above this point.
135  
136 0 warn "Internal error: unable to handle literal constant '$str'.",
137 " This is a bug, so please report this to the module author.";
138 0 return $int_class -> bnan();
139 }
140  
141 #############################################################################
142 # the following two routines are for "use bignum qw/hex oct/;":
143  
144 15 ▶use constant LEXICAL => $] > 5.009004;
Subroutine BEGIN: called CC=1 SCAR=0.0
145  
146 # Internal function with the same semantics as CORE::hex(). This function is
147 # not used directly, but rather by other front-end functions.
148  
149 1 ▶sub _hex_core {
Subroutine _hex_core: called CC=4 SCAR=15.2
150 1 my $str = shift;
151  
152 # Strip off, clean, and parse as much as we can from the beginning.
153  
154 1 my $x;
155 1 ▶ if ($str =~ s/ ^ ( 0? [xX] )? ( [0-9a-fA-F]* ( _ [0-9a-fA-F]+ )* ) //x) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ s/ ^ ( 0? [xX] )? ( [0-9a-fA-F]* ( _ [0-9a-fA-F]+ )* ) //x) { } 1 0 1
156 1 my $chrs = $2;
157 1 $chrs =~ tr/_//d;
158 1 ▶ $chrs = '0' unless CORE::length $chrs;
Branch: 1 branch
BranchTrueFalseTotal
unless length $chrs 0 1 1
159 1 $x = $int_class -> from_hex($chrs);
160 } else {
161 0 $x = $int_class -> bzero();
162 }
163  
164 # Warn about trailing garbage.
165  
166 1 ▶ if (CORE::length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $str) 0 1 1
167 0 require Carp;
168 0 Carp::carp(sprintf("Illegal hexadecimal digit '%s' ignored",
169 substr($str, 0, 1)));
170 }
171  
172 1 return $x;
173 }
174  
175 # Internal function with the same semantics as CORE::oct(). This function is
176 # not used directly, but rather by other front-end functions.
177  
178 1 ▶sub _oct_core {
Subroutine _oct_core: called CC=9 SCAR=31.6
179 1 my $str = shift;
180  
181 1 $str =~ s/^\s*//;
182  
183 # Hexadecimal input.
184  
185 1 ▶ return _hex_core($str) if $str =~ /^0?[xX]/;
Branch: 1 branch
BranchTrueFalseTotal
if $str =~ /^0?[xX]/ 0 1 1
186  
187 1 my $x;
188  
189 # Binary input.
190  
191 1 ▶ if ($str =~ /^0?[bB]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /^0?[bB]/) 0 1 1
192  
193 # Strip off, clean, and parse as much as we can from the beginning.
194  
195 0 ▶ if ($str =~ s/ ^ ( 0? [bB] )? ( [01]* ( _ [01]+ )* ) //x) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ s/ ^ ( 0? [bB] )? ( [01]* ( _ [01]+ )* ) //x) 0 0 0
196 0 my $chrs = $2;
197 0 $chrs =~ tr/_//d;
198 0 ▶ $chrs = '0' unless CORE::length $chrs;
Branch: 1 branch
BranchTrueFalseTotal
unless length $chrs 0 0 0
199 0 $x = $int_class -> from_bin($chrs);
200 }
201  
202 # Warn about trailing garbage.
203  
204 0 ▶ if (CORE::length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $str) 0 0 0
205 0 require Carp;
206 0 Carp::carp(sprintf("Illegal binary digit '%s' ignored",
207 substr($str, 0, 1)));
208 }
209  
210 0 return $x;
211 }
212  
213 # Octal input. Strip off, clean, and parse as much as we can from the
214 # beginning.
215  
216 1 ▶ if ($str =~ s/ ^ ( 0? [oO] )? ( [0-7]* ( _ [0-7]+ )* ) //x) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ s/ ^ ( 0? [oO] )? ( [0-7]* ( _ [0-7]+ )* ) //x) 1 0 1
217 1 my $chrs = $2;
218 1 $chrs =~ tr/_//d;
219 1 ▶ $chrs = '0' unless CORE::length $chrs;
Branch: 1 branch
BranchTrueFalseTotal
unless length $chrs 0 1 1
220 1 $x = $int_class -> from_oct($chrs);
221 }
222  
223 # Warn about trailing garbage. CORE::oct() only warns about 8 and 9, but it
224 # is more helpful to warn about all invalid digits.
225  
226 1 ▶ if (CORE::length($str)) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $str) 0 1 1
227 0 require Carp;
228 0 Carp::carp(sprintf("Illegal octal digit '%s' ignored",
229 substr($str, 0, 1)));
230 }
231  
232 1 return $x;
233 }
234  
235 {
236 15 my $proto = LEXICAL ? '_' : ';$';
237 0 ▶ eval '
Subroutine hex: not called CC=2 SCAR=14.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
238 sub hex(' . $proto . ') {' . <<'.';
239 my $str = @_ ? $_[0] : $_;
240 _hex_core($str);
241 }
242 .
243  
244 0 ▶ eval '
Subroutine oct: not called CC=2 SCAR=14.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
245 sub oct(' . $proto . ') {' . <<'.';
246 my $str = @_ ? $_[0] : $_;
247 _oct_core($str);
248 }
249 .
250 }
251  
252 #############################################################################
253 # the following two routines are for Perl 5.9.4 or later and are lexical
254  
255 15 my ($prev_oct, $prev_hex, $overridden);
256  
257 2 ▶if (LEXICAL) { eval <<'.' }
Subroutine _hex: called CC=5 SCAR=17.1
Subroutine _oct: called CC=5 SCAR=17.1
Branch: 8 branches
BranchTrueFalseTotal
$hh->{'bignum'} ? : 1 1 2
$hh->{'bigrat'} ? : 0 1 1
$hh->{'bigint'} ? : 0 1 1
$prev_hex ? : 0 1 1
$hh->{'bignum'} ? : 1 1 2
$hh->{'bigrat'} ? : 0 1 1
$hh->{'bigint'} ? : 0 1 1
$prev_oct ? : 0 1 1
258 sub _hex(_) {
259 my $hh = (caller 0)[10];
260 return $$hh{bignum} ? bignum::_hex_core($_[0])
261 : $$hh{bigrat} ? bigrat::_hex_core($_[0])
262 : $$hh{bigint} ? bigint::_hex_core($_[0])
263 : $prev_hex ? &$prev_hex($_[0])
264 : CORE::hex($_[0]);
265 }
266  
267 sub _oct(_) {
268 my $hh = (caller 0)[10];
269 return $$hh{bignum} ? bignum::_oct_core($_[0])
270 : $$hh{bigrat} ? bigrat::_oct_core($_[0])
271 : $$hh{bigint} ? bigint::_oct_core($_[0])
272 : $prev_oct ? &$prev_oct($_[0])
273 : CORE::oct($_[0]);
274 }
275 .
276  
277 46 ▶sub _override {
Subroutine _override: called CC=2 SCAR=6.9
278 46 ▶ return if $overridden;
Branch: 1 branch
BranchTrueFalseTotal
if $overridden 31 15 46
279 15 $prev_oct = *CORE::GLOBAL::oct{CODE};
280 15 $prev_hex = *CORE::GLOBAL::hex{CODE};
281 15 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
282 15 *CORE::GLOBAL::oct = \&_oct;
283 15 *CORE::GLOBAL::hex = \&_hex;
284 15 $overridden = 1;
285 }
286  
287 1 ▶sub unimport {
Subroutine unimport: called CC=1 SCAR=0.0
288 1 delete $^H{bignum}; # no longer in effect
289 1 overload::remove_constant('binary', '', 'float', '', 'integer');
290 }
291  
292 46 ▶sub import {
Subroutine import: called CC=17 SCAR=29.0
293 46 my $class = shift;
294  
295 46 $^H{bignum} = 1; # we are in effect
296 46 delete $^H{bigint};
297 46 delete $^H{bigrat};
298  
299 # for newer Perls always override hex() and oct() with a lexical version:
300 46 if (LEXICAL) {
301 46 _override();
302 }
303  
304 46 my @import = (); # common options
305 46 my @int_import = (upgrade => $float_class); # int class only options
306 46 my @flt_import = (downgrade => $int_class); # float class only options
307 46 my @a = (); # unrecognized arguments
308 46 my $ver; # display version info?
309  
310 46 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 41 26 67
311 41 my $param = shift;
312  
313 # Upgrading.
314  
315 41 ▶ if ($param eq 'upgrade') {
Branch: 1 branch
BranchTrueFalseTotal
if ($param eq "upgrade") 3 38 41
316 3 my $arg = shift;
317 3 ▶ $float_class = $arg if defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $arg 2 1 3
318 3 push @int_import, 'upgrade', $arg;
319 3 next;
320 }
321  
322 # Downgrading.
323  
324 38 ▶ if ($param eq 'downgrade') {
Branch: 1 branch
BranchTrueFalseTotal
if ($param eq "downgrade") 1 37 38
325 1 my $arg = shift;
326 1 ▶ $int_class = $arg if defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $arg 0 1 1
327 1 push @flt_import, 'downgrade', $arg;
328 1 next;
329 }
330  
331 # Accuracy.
332  
333 37 ▶ if ($param =~ /^a(ccuracy)?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($param =~ /^a(ccuracy)?$/) 2 35 37
334 2 push @import, 'accuracy', shift();
335 2 next;
336 }
337  
338 # Precision.
339  
340 35 ▶ if ($param =~ /^p(recision)?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($param =~ /^p(recision)?$/) 2 33 35
341 2 push @import, 'precision', shift();
342 2 next;
343 }
344  
345 # Rounding mode.
346  
347 33 ▶ if ($param eq 'round_mode') {
Branch: 1 branch
BranchTrueFalseTotal
if ($param eq "round_mode") 0 33 33
348 0 push @import, 'round_mode', shift();
349 0 next;
350 }
351  
352 # Backend library.
353  
354 33 ▶ if ($param =~ /^(l|lib|try|only)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($param =~ /^(l|lib|try|only)$/) 9 24 33
355 9 ▶ push @import, $param eq 'l' ? 'lib' : $param;
Branch: 1 branch
BranchTrueFalseTotal
$param eq 'l' ? : 2 7 9
356 9 ▶ push @import, shift() if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 9 0 9
357 9 next;
358 }
359  
360 24 ▶ if ($param =~ /^(v|version)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($param =~ /^(v|version)$/) 0 24 24
361 0 $ver = 1;
362 0 next;
363 }
364  
365 24 ▶ if ($param =~ /^(PI|e|bexp|bpi|hex|oct)\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($param =~ /^(PI|e|bexp|bpi|hex|oct)\z/) 4 20 24
366 4 push @a, $param;
367 4 next;
368 }
369  
370 20 croak("Unknown option '$param'");
371 }
372  
373 26 eval "require $int_class";
374 26 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 26 26
375 26 $int_class -> import(@int_import, @import);
376  
377 26 eval "require $float_class";
378 26 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 26 26
379 26 $float_class -> import(@flt_import, @import);
380  
381 26 ▶ if ($ver) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ver) 0 26 26
382 0 printf "%-31s v%s\n", $class, $class -> VERSION();
383 0 printf " lib => %-23s v%s\n",
384 $int_class -> config("lib"), $int_class -> config("lib_version");
385 0 printf "%-31s v%s\n", $int_class, $int_class -> VERSION();
386 0 exit;
387 }
388  
389 26 $class -> export_to_level(1, $class, @a); # export inf, NaN, etc.
390  
391 overload::constant
392  
393 # This takes care each number written as decimal integer and within the
394 # range of what perl can represent as an integer, e.g., "314", but not
395 # "3141592653589793238462643383279502884197169399375105820974944592307".
396  
397 58 ▶ integer => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
398 #printf "Value '%s' handled by the 'integer' sub.\n", $_[0];
399 58 my $str = shift;
400 58 return $int_class -> new($str);
401 },
402  
403 # This takes care of each number written with a decimal point and/or
404 # using floating point notation, e.g., "3.", "3.0", "3.14e+2" (decimal),
405 # "0b1.101p+2" (binary), "03.14p+2" and "0o3.14p+2" (octal), and
406 # "0x3.14p+2" (hexadecimal).
407  
408 91 ▶ float => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
409 #printf "# Value '%s' handled by the 'float' sub.\n", $_[0];
410 91 _float_constant(shift);
411 },
412  
413 # Take care of each number written as an integer (no decimal point or
414 # exponent) using binary, octal, or hexadecimal notation, e.g., "0b101"
415 # (binary), "0314" and "0o314" (octal), and "0x314" (hexadecimal).
416  
417 12 ▶ binary => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
418 #printf "# Value '%s' handled by the 'binary' sub.\n", $_[0];
419 12 my $str = shift;
420 12 ▶ return $int_class -> new($str) if $str =~ /^0[XxBb]/;
Branch: 1 branch
BranchTrueFalseTotal
if $str =~ /^0[XxBb]/ 7 5 12
421 5 $int_class -> from_oct($str);
422 26 };
423 }
424  
425 22 ▶sub inf () { $int_class -> binf(); }
Subroutine inf: called CC=1 SCAR=0.0
Pod documented
426 20 ▶sub NaN () { $int_class -> bnan(); }
Subroutine NaN: called CC=1 SCAR=0.0
Pod documented
427  
428 # This should depend on the current accuracy/precision. Fixme!
429 1 ▶sub PI () { $float_class -> new('3.141592653589793238462643383279502884197'); }
Subroutine PI: called CC=1 SCAR=0.0
Pod documented
430 1 ▶sub e () { $float_class -> new('2.718281828459045235360287471352662497757'); }
Subroutine e: called CC=1 SCAR=0.0
Pod documented
431  
432 1 ▶sub bpi ($) {
Subroutine bpi: called CC=1 SCAR=0.0
Pod documented
433 1 my $up = Math::BigFloat -> upgrade(); # get current upgrading, if any ...
434 1 Math::BigFloat -> upgrade(undef); # ... and disable
435 1 my $x = Math::BigFloat -> bpi(@_);
436 1 Math::BigFloat -> upgrade($up); # reset the upgrading
437 1 return $x;
438 }
439  
440 1 ▶sub bexp ($$) {
Subroutine bexp: called CC=1 SCAR=0.0
Pod documented
441 1 my $up = Math::BigFloat -> upgrade(); # get current upgrading, if any ...
442 1 Math::BigFloat -> upgrade(undef); # ... and disable
443 1 my $x = Math::BigFloat -> new(shift) -> bexp(@_);
444 1 Math::BigFloat -> upgrade($up); # reset the upgrading
445 1 return $x;
446 }
447  
448 15 1;
449  
450 __END__
↑ Summary bigint.pm »