line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- mode: perl; -*- |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Math::BigInt::Named; |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
224261
|
use 5.006001; |
|
5
|
|
|
|
|
42
|
|
6
|
5
|
|
|
5
|
|
25
|
use strict; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
104
|
|
7
|
5
|
|
|
5
|
|
17
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
175
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
36
|
use Carp qw( carp croak ); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
269
|
|
10
|
|
|
|
|
|
|
|
11
|
5
|
|
|
5
|
|
10914
|
use Math::BigInt 1.97; |
|
5
|
|
|
|
|
137458
|
|
|
5
|
|
|
|
|
29
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(Math::BigInt); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Globals. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our ($accuracy, $precision, $round_mode, $div_scale); |
19
|
|
|
|
|
|
|
$accuracy = undef; |
20
|
|
|
|
|
|
|
$precision = undef; |
21
|
|
|
|
|
|
|
$round_mode = 'even'; |
22
|
|
|
|
|
|
|
$div_scale = 40; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Not all of them exist yet. |
25
|
|
|
|
|
|
|
my $LANGUAGE = { |
26
|
|
|
|
|
|
|
en => 'english', |
27
|
|
|
|
|
|
|
de => 'german', |
28
|
|
|
|
|
|
|
sp => 'spanish', |
29
|
|
|
|
|
|
|
fr => 'french', |
30
|
|
|
|
|
|
|
ro => 'romana', |
31
|
|
|
|
|
|
|
it => 'italian', |
32
|
|
|
|
|
|
|
no => 'norwegian', |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Index of languages that have been loaded. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $LOADED = { }; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub name { |
40
|
|
|
|
|
|
|
# output the name of the number |
41
|
61
|
|
|
61
|
1
|
51723
|
my $x = shift; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# make Math::BigInt::Named -> name(123) work |
44
|
61
|
100
|
|
|
|
269
|
$x = $x -> new(shift) unless ref($x); |
45
|
|
|
|
|
|
|
|
46
|
61
|
100
|
|
|
|
307
|
return 'NaN' if $x -> is_nan(); |
47
|
|
|
|
|
|
|
|
48
|
60
|
|
|
|
|
542
|
my @args = (); |
49
|
60
|
100
|
|
|
|
331
|
if (@_) { |
50
|
58
|
50
|
|
|
|
198
|
if (ref($_[0]) eq 'HASH') { |
51
|
0
|
0
|
|
|
|
0
|
carp "When the options are given as a hash ref, additional", |
52
|
|
|
|
|
|
|
" arguments are ignored" if @_ > 1; |
53
|
0
|
|
|
|
|
0
|
@args = %{ $_[0] }; |
|
0
|
|
|
|
|
0
|
|
54
|
|
|
|
|
|
|
} else { |
55
|
58
|
|
|
|
|
155
|
@args = @_; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
60
|
|
|
|
|
92
|
my $lang; |
60
|
60
|
|
|
|
|
169
|
while (@args) { |
61
|
58
|
|
|
|
|
180
|
my $param = shift @args; |
62
|
58
|
50
|
|
|
|
201
|
croak "Parameter name can not be undefined" unless defined $param; |
63
|
58
|
50
|
|
|
|
229
|
croak "Parameter name can not be an empty string" unless length $param; |
64
|
|
|
|
|
|
|
|
65
|
58
|
50
|
|
|
|
339
|
if ($param =~ /^lang(uage)?$/) { |
66
|
58
|
|
|
|
|
125
|
$lang = shift @args; |
67
|
58
|
50
|
|
|
|
136
|
croak "Language can not be undefined" unless defined $lang; |
68
|
58
|
50
|
|
|
|
151
|
croak "Language can not be an empty string" unless length $lang; |
69
|
58
|
|
|
|
|
149
|
next; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
0
|
croak "Invalid parameter '$param'"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
60
|
100
|
|
|
|
133
|
$lang = 'english' unless defined $lang; |
76
|
60
|
100
|
|
|
|
235
|
$lang = $LANGUAGE -> {$lang} if exists $LANGUAGE -> {$lang}; # en => english |
77
|
|
|
|
|
|
|
|
78
|
60
|
|
|
|
|
209
|
$lang = 'Math::BigInt::Named::' . ucfirst($lang); |
79
|
|
|
|
|
|
|
|
80
|
60
|
100
|
|
|
|
190
|
if (!defined $LOADED -> {$lang}) { |
81
|
4
|
|
|
|
|
9
|
my $file = $lang; |
82
|
4
|
|
|
|
|
24
|
$file =~ s|::|/|g; |
83
|
4
|
|
|
|
|
8
|
$file .= ".pm"; |
84
|
4
|
|
|
|
|
8
|
eval { require $file; }; |
|
4
|
|
|
|
|
2007
|
|
85
|
4
|
50
|
|
|
|
17
|
croak $@ if $@; |
86
|
4
|
|
|
|
|
11
|
$LOADED -> {$lang} = 1; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
60
|
|
|
|
|
303
|
my $y = $lang -> new($x); |
90
|
60
|
|
|
|
|
15191
|
$y -> name(); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub from_name { |
94
|
|
|
|
|
|
|
# Create a Math::BigInt::Named from a name string. Not implemented. |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
0
|
1
|
|
my $x = Math::BigInt -> bnan(); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |