line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Int128; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
48342
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
114
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
250
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# The "our $VERSION" bit needs to be at the beginning of the line for the |
7
|
|
|
|
|
|
|
# benefit of the RewriteVersion plugin. |
8
|
|
|
|
|
|
|
BEGIN { |
9
|
3
|
|
|
3
|
|
7
|
our $VERSION = '0.21'; |
10
|
3
|
|
|
|
|
12
|
require XSLoader; |
11
|
3
|
|
|
|
|
3546
|
XSLoader::load('Math::Int128', $VERSION); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
13210
|
use Math::Int64 0.51; |
|
3
|
|
|
|
|
72
|
|
|
3
|
|
|
|
|
16
|
|
15
|
|
|
|
|
|
|
|
16
|
3
|
|
|
3
|
|
315
|
use constant MAX_INT128 => string_to_int128 ( '0x7fff_ffff_ffff_ffff_ffff_ffff_ffff_ffff'); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
226
|
|
17
|
3
|
|
|
3
|
|
14
|
use constant MIN_INT128 => string_to_int128 ('-0x8000_0000_0000_0000_0000_0000_0000_0000'); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
141
|
|
18
|
3
|
|
|
3
|
|
11
|
use constant MAX_UINT128 => string_to_uint128( '0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff'); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
743
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
require Exporter; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( ctors => [qw( int128 uint128 |
25
|
|
|
|
|
|
|
string_to_int128 |
26
|
|
|
|
|
|
|
string_to_uint128 )], |
27
|
|
|
|
|
|
|
pack => [qw( int128_to_number |
28
|
|
|
|
|
|
|
int128_to_hex |
29
|
|
|
|
|
|
|
net_to_int128 |
30
|
|
|
|
|
|
|
int128_to_net |
31
|
|
|
|
|
|
|
native_to_int128 |
32
|
|
|
|
|
|
|
int128_to_native |
33
|
|
|
|
|
|
|
uint128_to_number |
34
|
|
|
|
|
|
|
uint128_to_hex |
35
|
|
|
|
|
|
|
net_to_uint128 |
36
|
|
|
|
|
|
|
uint128_to_net |
37
|
|
|
|
|
|
|
native_to_uint128 |
38
|
|
|
|
|
|
|
uint128_to_native )], |
39
|
|
|
|
|
|
|
op => [qw( int128_set |
40
|
|
|
|
|
|
|
int128_inc |
41
|
|
|
|
|
|
|
int128_dec |
42
|
|
|
|
|
|
|
int128_add |
43
|
|
|
|
|
|
|
int128_sub |
44
|
|
|
|
|
|
|
int128_mul |
45
|
|
|
|
|
|
|
int128_pow |
46
|
|
|
|
|
|
|
int128_div |
47
|
|
|
|
|
|
|
int128_mod |
48
|
|
|
|
|
|
|
int128_divmod |
49
|
|
|
|
|
|
|
int128_neg |
50
|
|
|
|
|
|
|
int128_not |
51
|
|
|
|
|
|
|
int128_and |
52
|
|
|
|
|
|
|
int128_or |
53
|
|
|
|
|
|
|
int128_xor |
54
|
|
|
|
|
|
|
int128_left |
55
|
|
|
|
|
|
|
int128_right |
56
|
|
|
|
|
|
|
int128_average |
57
|
|
|
|
|
|
|
uint128_set |
58
|
|
|
|
|
|
|
uint128_inc |
59
|
|
|
|
|
|
|
uint128_dec |
60
|
|
|
|
|
|
|
uint128_add |
61
|
|
|
|
|
|
|
uint128_sub |
62
|
|
|
|
|
|
|
uint128_mul |
63
|
|
|
|
|
|
|
uint128_pow |
64
|
|
|
|
|
|
|
uint128_div |
65
|
|
|
|
|
|
|
uint128_mod |
66
|
|
|
|
|
|
|
uint128_divmod |
67
|
|
|
|
|
|
|
uint128_not |
68
|
|
|
|
|
|
|
uint128_and |
69
|
|
|
|
|
|
|
uint128_or |
70
|
|
|
|
|
|
|
uint128_xor |
71
|
|
|
|
|
|
|
uint128_left |
72
|
|
|
|
|
|
|
uint128_right |
73
|
|
|
|
|
|
|
uint128_average)], |
74
|
|
|
|
|
|
|
limits => [qw( MAX_INT128 |
75
|
|
|
|
|
|
|
MIN_INT128 |
76
|
|
|
|
|
|
|
MAX_UINT128 )] ); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
our @EXPORT_OK = map @$_, values %EXPORT_TAGS; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
3
|
|
|
|
|
19
|
use overload ( '+' => \&_add, |
82
|
|
|
|
|
|
|
'+=' => \&_add, |
83
|
|
|
|
|
|
|
'-' => \&_sub, |
84
|
|
|
|
|
|
|
'-=' => \&_sub, |
85
|
|
|
|
|
|
|
'*' => \&_mul, |
86
|
|
|
|
|
|
|
'*=' => \&_mul, |
87
|
|
|
|
|
|
|
'**' => \&_pow, |
88
|
|
|
|
|
|
|
'**=' => \&_pow, |
89
|
|
|
|
|
|
|
'/' => \&_div, |
90
|
|
|
|
|
|
|
'/=' => \&_div, |
91
|
|
|
|
|
|
|
'%' => \&_remainder, |
92
|
|
|
|
|
|
|
'%=' => \&_remainder, |
93
|
|
|
|
|
|
|
'neg' => \&_neg, |
94
|
|
|
|
|
|
|
'++' => \&_inc, |
95
|
|
|
|
|
|
|
'--' => \&_dec, |
96
|
|
|
|
|
|
|
'!' => \&_not, |
97
|
|
|
|
|
|
|
'~' => \&_bnot, |
98
|
|
|
|
|
|
|
'&' => \&_and, |
99
|
|
|
|
|
|
|
'|' => \&_or, |
100
|
|
|
|
|
|
|
'^' => \&_xor, |
101
|
|
|
|
|
|
|
'<<' => \&_left, |
102
|
|
|
|
|
|
|
'>>' => \&_right, |
103
|
|
|
|
|
|
|
'<=>' => \&_spaceship, |
104
|
|
|
|
|
|
|
'>' => \&_gtn, |
105
|
|
|
|
|
|
|
'<' => \&_ltn, |
106
|
|
|
|
|
|
|
'>=' => \&_gen, |
107
|
|
|
|
|
|
|
'<=' => \&_len, |
108
|
|
|
|
|
|
|
'==' => \&_eqn, |
109
|
|
|
|
|
|
|
'!=' => \&_nen, |
110
|
|
|
|
|
|
|
'bool' => \&_bool, |
111
|
|
|
|
|
|
|
'0+' => \&_number, |
112
|
|
|
|
|
|
|
'""' => \&_string, |
113
|
|
|
|
|
|
|
'=' => \&_clone, |
114
|
3
|
|
|
3
|
|
13
|
fallback => 1 ); |
|
3
|
|
|
|
|
4
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
package Math::UInt128; |
117
|
3
|
|
|
|
|
17
|
use overload ( '+' => \&_add, |
118
|
|
|
|
|
|
|
'+=' => \&_add, |
119
|
|
|
|
|
|
|
'-' => \&_sub, |
120
|
|
|
|
|
|
|
'-=' => \&_sub, |
121
|
|
|
|
|
|
|
'*' => \&_mul, |
122
|
|
|
|
|
|
|
'*=' => \&_mul, |
123
|
|
|
|
|
|
|
'**' => \&_pow, |
124
|
|
|
|
|
|
|
'**=' => \&_pow, |
125
|
|
|
|
|
|
|
'/' => \&_div, |
126
|
|
|
|
|
|
|
'/=' => \&_div, |
127
|
|
|
|
|
|
|
'%' => \&_remainder, |
128
|
|
|
|
|
|
|
'%=' => \&_remainder, |
129
|
|
|
|
|
|
|
'neg' => \&_neg, |
130
|
|
|
|
|
|
|
'++' => \&_inc, |
131
|
|
|
|
|
|
|
'--' => \&_dec, |
132
|
|
|
|
|
|
|
'!' => \&_not, |
133
|
|
|
|
|
|
|
'~' => \&_bnot, |
134
|
|
|
|
|
|
|
'&' => \&_and, |
135
|
|
|
|
|
|
|
'|' => \&_or, |
136
|
|
|
|
|
|
|
'^' => \&_xor, |
137
|
|
|
|
|
|
|
'<<' => \&_left, |
138
|
|
|
|
|
|
|
'>>' => \&_right, |
139
|
|
|
|
|
|
|
'<=>' => \&_spaceship, |
140
|
|
|
|
|
|
|
'>' => \&_gtn, |
141
|
|
|
|
|
|
|
'<' => \&_ltn, |
142
|
|
|
|
|
|
|
'>=' => \&_gen, |
143
|
|
|
|
|
|
|
'<=' => \&_len, |
144
|
|
|
|
|
|
|
'==' => \&_eqn, |
145
|
|
|
|
|
|
|
'!=' => \&_nen, |
146
|
|
|
|
|
|
|
'bool' => \&_bool, |
147
|
|
|
|
|
|
|
'0+' => \&_number, |
148
|
|
|
|
|
|
|
'""' => \&_string, |
149
|
|
|
|
|
|
|
'=' => \&_clone, |
150
|
3
|
|
|
3
|
|
1055
|
fallback => 1 ); |
|
3
|
|
|
|
|
4
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
__END__ |