line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# This file was autogenerated. |
2
|
3
|
|
|
3
|
|
227487
|
use 5.008001; |
|
3
|
|
|
|
|
45
|
|
3
|
3
|
|
|
3
|
|
24
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
63
|
|
4
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
82
|
|
5
|
3
|
|
|
3
|
|
14
|
no warnings qw( void once ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
85
|
|
6
|
3
|
|
|
3
|
|
387
|
use Hydrogen (); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
218
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Hydrogen::Number; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
11
|
|
|
|
|
|
|
our $VERSION = '0.017'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Hydrogen::Number - a standard library for numbers |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This documentation is for Hydrogen::Number 0.017, |
20
|
|
|
|
|
|
|
which is based on Sub::HandlesVia::HandlerLibrary::Number 0.038. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 FUNCTIONS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Each function expects a numeric scalar as its first argument. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
28
|
use Exporter::Shiny qw( |
31
|
|
|
|
|
|
|
abs |
32
|
|
|
|
|
|
|
add |
33
|
|
|
|
|
|
|
cmp |
34
|
|
|
|
|
|
|
div |
35
|
|
|
|
|
|
|
eq |
36
|
|
|
|
|
|
|
ge |
37
|
|
|
|
|
|
|
get |
38
|
|
|
|
|
|
|
gt |
39
|
|
|
|
|
|
|
le |
40
|
|
|
|
|
|
|
lt |
41
|
|
|
|
|
|
|
mod |
42
|
|
|
|
|
|
|
mul |
43
|
|
|
|
|
|
|
ne |
44
|
|
|
|
|
|
|
set |
45
|
|
|
|
|
|
|
sub |
46
|
3
|
|
|
3
|
|
20
|
); |
|
3
|
|
|
|
|
7
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 C<< abs( $number ) >> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Finds the absolute value of the current number, updating the original value. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub abs { |
55
|
1
|
|
|
1
|
1
|
7364
|
my $__REF__ = \$_[0]; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
58
|
1
|
50
|
|
|
|
5
|
@_ == 1 |
59
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for abs; usage: " |
60
|
|
|
|
|
|
|
. "Hydrogen::Number::abs( \$number )" ); |
61
|
1
|
|
|
|
|
2
|
1; |
62
|
1
|
|
|
|
|
3
|
( ${$__REF__} = abs($$__REF__) ); |
|
1
|
|
|
|
|
3
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 C<< add( $number, $addend ) >> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Additional arguments: B<< Num >>. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Adds a number to the existing number, updating the original value. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub add { |
74
|
1
|
|
|
1
|
1
|
3434
|
my $__REF__ = \$_[0]; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
77
|
1
|
|
|
|
|
3
|
@_ = do { |
78
|
1
|
|
|
|
|
4
|
my ( %tmp, $tmp ); |
79
|
|
|
|
|
|
|
|
80
|
1
|
50
|
|
|
|
4
|
@_ == 2 |
81
|
|
|
|
|
|
|
or Hydrogen::croak( |
82
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
83
|
|
|
|
|
|
|
"add", scalar(@_), "expected exactly 2 parameters" ); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Parameter $_[0] (type: Num) |
86
|
|
|
|
|
|
|
( |
87
|
1
|
50
|
|
|
|
2
|
do { |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
90
|
3
|
|
|
3
|
|
639
|
use Scalar::Util (); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
241
|
|
91
|
1
|
50
|
33
|
|
|
15
|
defined( $_[0] ) |
92
|
|
|
|
|
|
|
&& !ref( $_[0] ) |
93
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[0] ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
) |
96
|
|
|
|
|
|
|
or Hydrogen::croak( |
97
|
|
|
|
|
|
|
"Type check failed in signature for add: %s should be %s", |
98
|
|
|
|
|
|
|
"\$_[0]", "Num" ); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# Parameter $_[1] (type: Num) |
101
|
|
|
|
|
|
|
( |
102
|
1
|
50
|
|
|
|
2
|
do { |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
105
|
3
|
|
|
3
|
|
25
|
use Scalar::Util (); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
349
|
|
106
|
1
|
50
|
33
|
|
|
11
|
defined( $_[1] ) |
107
|
|
|
|
|
|
|
&& !ref( $_[1] ) |
108
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[1] ); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
) |
111
|
|
|
|
|
|
|
or Hydrogen::croak( |
112
|
|
|
|
|
|
|
"Type check failed in signature for add: %s should be %s", |
113
|
|
|
|
|
|
|
"\$_[1]", "Num" ); |
114
|
|
|
|
|
|
|
|
115
|
1
|
|
|
|
|
4
|
(@_); |
116
|
|
|
|
|
|
|
}; |
117
|
|
|
|
|
|
|
( |
118
|
1
|
|
|
|
|
3
|
${$__REF__} = do { |
|
1
|
|
|
|
|
30
|
|
119
|
1
|
|
|
|
|
2
|
my $shv_final_unchecked = $$__REF__ + $_[1]; |
120
|
1
|
|
|
|
|
2
|
do { |
121
|
|
|
|
|
|
|
( |
122
|
1
|
50
|
|
|
|
2
|
do { |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
125
|
3
|
|
|
3
|
|
19
|
use Scalar::Util (); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
454
|
|
126
|
1
|
50
|
33
|
|
|
20
|
defined($shv_final_unchecked) |
127
|
|
|
|
|
|
|
&& !ref($shv_final_unchecked) |
128
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( |
129
|
|
|
|
|
|
|
$shv_final_unchecked); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
) |
132
|
|
|
|
|
|
|
or Hydrogen::croak( |
133
|
|
|
|
|
|
|
"Type check failed for add: expected %s, got value %s", |
134
|
|
|
|
|
|
|
"Num", $shv_final_unchecked ); |
135
|
1
|
|
|
|
|
7
|
$shv_final_unchecked; |
136
|
|
|
|
|
|
|
}; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 C<< cmp( $number, $num ) >> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Additional arguments: B<< Num >>. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Returns C<< $number <=> $num >>. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub cmp { |
150
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
153
|
0
|
|
|
|
|
0
|
@_ = do { |
154
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
155
|
|
|
|
|
|
|
|
156
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
157
|
|
|
|
|
|
|
or Hydrogen::croak( |
158
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
159
|
|
|
|
|
|
|
"cmp", scalar(@_), "expected exactly 2 parameters" ); |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Parameter $_[0] (type: Num) |
162
|
|
|
|
|
|
|
( |
163
|
0
|
0
|
|
|
|
0
|
do { |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
166
|
3
|
|
|
3
|
|
32
|
use Scalar::Util (); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
236
|
|
167
|
0
|
0
|
0
|
|
|
0
|
defined( $_[0] ) |
168
|
|
|
|
|
|
|
&& !ref( $_[0] ) |
169
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[0] ); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
) |
172
|
|
|
|
|
|
|
or Hydrogen::croak( |
173
|
|
|
|
|
|
|
"Type check failed in signature for cmp: %s should be %s", |
174
|
|
|
|
|
|
|
"\$_[0]", "Num" ); |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# Parameter $_[1] (type: Num) |
177
|
|
|
|
|
|
|
( |
178
|
0
|
0
|
|
|
|
0
|
do { |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
181
|
3
|
|
|
3
|
|
19
|
use Scalar::Util (); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
524
|
|
182
|
0
|
0
|
0
|
|
|
0
|
defined( $_[1] ) |
183
|
|
|
|
|
|
|
&& !ref( $_[1] ) |
184
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[1] ); |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
) |
187
|
|
|
|
|
|
|
or Hydrogen::croak( |
188
|
|
|
|
|
|
|
"Type check failed in signature for cmp: %s should be %s", |
189
|
|
|
|
|
|
|
"\$_[1]", "Num" ); |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
0
|
(@_); |
192
|
|
|
|
|
|
|
}; |
193
|
0
|
|
|
|
|
0
|
$$__REF__ <=> $_[1]; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 C<< div( $number, $divisor ) >> |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Additional arguments: B<< Num >>. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Divides the existing number by a number, updating the original value. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=cut |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub div { |
205
|
1
|
|
|
1
|
1
|
4627
|
my $__REF__ = \$_[0]; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
208
|
1
|
|
|
|
|
25
|
@_ = do { |
209
|
1
|
|
|
|
|
5
|
my ( %tmp, $tmp ); |
210
|
|
|
|
|
|
|
|
211
|
1
|
50
|
|
|
|
5
|
@_ == 2 |
212
|
|
|
|
|
|
|
or Hydrogen::croak( |
213
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
214
|
|
|
|
|
|
|
"div", scalar(@_), "expected exactly 2 parameters" ); |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
# Parameter $_[0] (type: Num) |
217
|
|
|
|
|
|
|
( |
218
|
1
|
50
|
|
|
|
2
|
do { |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
221
|
3
|
|
|
3
|
|
21
|
use Scalar::Util (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
225
|
|
222
|
1
|
50
|
33
|
|
|
12
|
defined( $_[0] ) |
223
|
|
|
|
|
|
|
&& !ref( $_[0] ) |
224
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[0] ); |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
) |
227
|
|
|
|
|
|
|
or Hydrogen::croak( |
228
|
|
|
|
|
|
|
"Type check failed in signature for div: %s should be %s", |
229
|
|
|
|
|
|
|
"\$_[0]", "Num" ); |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
# Parameter $_[1] (type: Num) |
232
|
|
|
|
|
|
|
( |
233
|
1
|
50
|
|
|
|
3
|
do { |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
236
|
3
|
|
|
3
|
|
19
|
use Scalar::Util (); |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
324
|
|
237
|
1
|
50
|
33
|
|
|
9
|
defined( $_[1] ) |
238
|
|
|
|
|
|
|
&& !ref( $_[1] ) |
239
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[1] ); |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
) |
242
|
|
|
|
|
|
|
or Hydrogen::croak( |
243
|
|
|
|
|
|
|
"Type check failed in signature for div: %s should be %s", |
244
|
|
|
|
|
|
|
"\$_[1]", "Num" ); |
245
|
|
|
|
|
|
|
|
246
|
1
|
|
|
|
|
4
|
(@_); |
247
|
|
|
|
|
|
|
}; |
248
|
|
|
|
|
|
|
( |
249
|
1
|
|
|
|
|
2
|
${$__REF__} = do { |
|
1
|
|
|
|
|
3
|
|
250
|
1
|
|
|
|
|
4
|
my $shv_final_unchecked = $$__REF__ / $_[1]; |
251
|
1
|
|
|
|
|
2
|
do { |
252
|
|
|
|
|
|
|
( |
253
|
1
|
50
|
|
|
|
2
|
do { |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
256
|
3
|
|
|
3
|
|
32
|
use Scalar::Util (); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
422
|
|
257
|
1
|
50
|
33
|
|
|
9
|
defined($shv_final_unchecked) |
258
|
|
|
|
|
|
|
&& !ref($shv_final_unchecked) |
259
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( |
260
|
|
|
|
|
|
|
$shv_final_unchecked); |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
) |
263
|
|
|
|
|
|
|
or Hydrogen::croak( |
264
|
|
|
|
|
|
|
"Type check failed for div: expected %s, got value %s", |
265
|
|
|
|
|
|
|
"Num", $shv_final_unchecked ); |
266
|
1
|
|
|
|
|
3
|
$shv_final_unchecked; |
267
|
|
|
|
|
|
|
}; |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
); |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head2 C<< eq( $number, $num ) >> |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Additional arguments: B<< Num >>. |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
Returns C<< $number == $num >>. |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=cut |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
sub eq { |
281
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
284
|
0
|
|
|
|
|
0
|
@_ = do { |
285
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
286
|
|
|
|
|
|
|
|
287
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
288
|
|
|
|
|
|
|
or Hydrogen::croak( |
289
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
290
|
|
|
|
|
|
|
"eq", scalar(@_), "expected exactly 2 parameters" ); |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
# Parameter $_[0] (type: Num) |
293
|
|
|
|
|
|
|
( |
294
|
0
|
0
|
|
|
|
0
|
do { |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
297
|
3
|
|
|
3
|
|
65
|
use Scalar::Util (); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
240
|
|
298
|
0
|
0
|
0
|
|
|
0
|
defined( $_[0] ) |
299
|
|
|
|
|
|
|
&& !ref( $_[0] ) |
300
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[0] ); |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
) |
303
|
|
|
|
|
|
|
or Hydrogen::croak( |
304
|
|
|
|
|
|
|
"Type check failed in signature for eq: %s should be %s", |
305
|
|
|
|
|
|
|
"\$_[0]", "Num" ); |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
# Parameter $_[1] (type: Num) |
308
|
|
|
|
|
|
|
( |
309
|
0
|
0
|
|
|
|
0
|
do { |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
312
|
3
|
|
|
3
|
|
20
|
use Scalar::Util (); |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
615
|
|
313
|
0
|
0
|
0
|
|
|
0
|
defined( $_[1] ) |
314
|
|
|
|
|
|
|
&& !ref( $_[1] ) |
315
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[1] ); |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
) |
318
|
|
|
|
|
|
|
or Hydrogen::croak( |
319
|
|
|
|
|
|
|
"Type check failed in signature for eq: %s should be %s", |
320
|
|
|
|
|
|
|
"\$_[1]", "Num" ); |
321
|
|
|
|
|
|
|
|
322
|
0
|
|
|
|
|
0
|
(@_); |
323
|
|
|
|
|
|
|
}; |
324
|
0
|
|
|
|
|
0
|
$$__REF__ == $_[1]; |
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=head2 C<< ge( $number, $num ) >> |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
Additional arguments: B<< Num >>. |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
Returns C<< $number >= $num >>. |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
=cut |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
sub ge { |
336
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
339
|
0
|
|
|
|
|
0
|
@_ = do { |
340
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
341
|
|
|
|
|
|
|
|
342
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
343
|
|
|
|
|
|
|
or Hydrogen::croak( |
344
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
345
|
|
|
|
|
|
|
"ge", scalar(@_), "expected exactly 2 parameters" ); |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
# Parameter $_[0] (type: Num) |
348
|
|
|
|
|
|
|
( |
349
|
0
|
0
|
|
|
|
0
|
do { |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
352
|
3
|
|
|
3
|
|
21
|
use Scalar::Util (); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
211
|
|
353
|
0
|
0
|
0
|
|
|
0
|
defined( $_[0] ) |
354
|
|
|
|
|
|
|
&& !ref( $_[0] ) |
355
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[0] ); |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
) |
358
|
|
|
|
|
|
|
or Hydrogen::croak( |
359
|
|
|
|
|
|
|
"Type check failed in signature for ge: %s should be %s", |
360
|
|
|
|
|
|
|
"\$_[0]", "Num" ); |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
# Parameter $_[1] (type: Num) |
363
|
|
|
|
|
|
|
( |
364
|
0
|
0
|
|
|
|
0
|
do { |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
367
|
3
|
|
|
3
|
|
20
|
use Scalar::Util (); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
682
|
|
368
|
0
|
0
|
0
|
|
|
0
|
defined( $_[1] ) |
369
|
|
|
|
|
|
|
&& !ref( $_[1] ) |
370
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[1] ); |
371
|
|
|
|
|
|
|
} |
372
|
|
|
|
|
|
|
) |
373
|
|
|
|
|
|
|
or Hydrogen::croak( |
374
|
|
|
|
|
|
|
"Type check failed in signature for ge: %s should be %s", |
375
|
|
|
|
|
|
|
"\$_[1]", "Num" ); |
376
|
|
|
|
|
|
|
|
377
|
0
|
|
|
|
|
0
|
(@_); |
378
|
|
|
|
|
|
|
}; |
379
|
0
|
|
|
|
|
0
|
$$__REF__ >= $_[1]; |
380
|
|
|
|
|
|
|
} |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
=head2 C<< get( $number ) >> |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
Returns the current value of the number. |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
=cut |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
sub get { |
389
|
1
|
|
|
1
|
1
|
6444
|
my $__REF__ = \$_[0]; |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
392
|
1
|
50
|
|
|
|
7
|
@_ == 1 |
393
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for get; usage: " |
394
|
|
|
|
|
|
|
. "Hydrogen::Number::get( \$number )" ); |
395
|
1
|
|
|
|
|
5
|
$$__REF__; |
396
|
|
|
|
|
|
|
} |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
=head2 C<< gt( $number, $num ) >> |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
Additional arguments: B<< Num >>. |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
Returns C<< $number > $num >>. |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
=cut |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
sub gt { |
407
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
410
|
0
|
|
|
|
|
0
|
@_ = do { |
411
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
412
|
|
|
|
|
|
|
|
413
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
414
|
|
|
|
|
|
|
or Hydrogen::croak( |
415
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
416
|
|
|
|
|
|
|
"gt", scalar(@_), "expected exactly 2 parameters" ); |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
# Parameter $_[0] (type: Num) |
419
|
|
|
|
|
|
|
( |
420
|
0
|
0
|
|
|
|
0
|
do { |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
423
|
3
|
|
|
3
|
|
20
|
use Scalar::Util (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
231
|
|
424
|
0
|
0
|
0
|
|
|
0
|
defined( $_[0] ) |
425
|
|
|
|
|
|
|
&& !ref( $_[0] ) |
426
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[0] ); |
427
|
|
|
|
|
|
|
} |
428
|
|
|
|
|
|
|
) |
429
|
|
|
|
|
|
|
or Hydrogen::croak( |
430
|
|
|
|
|
|
|
"Type check failed in signature for gt: %s should be %s", |
431
|
|
|
|
|
|
|
"\$_[0]", "Num" ); |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
# Parameter $_[1] (type: Num) |
434
|
|
|
|
|
|
|
( |
435
|
0
|
0
|
|
|
|
0
|
do { |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
438
|
3
|
|
|
3
|
|
19
|
use Scalar::Util (); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
536
|
|
439
|
0
|
0
|
0
|
|
|
0
|
defined( $_[1] ) |
440
|
|
|
|
|
|
|
&& !ref( $_[1] ) |
441
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[1] ); |
442
|
|
|
|
|
|
|
} |
443
|
|
|
|
|
|
|
) |
444
|
|
|
|
|
|
|
or Hydrogen::croak( |
445
|
|
|
|
|
|
|
"Type check failed in signature for gt: %s should be %s", |
446
|
|
|
|
|
|
|
"\$_[1]", "Num" ); |
447
|
|
|
|
|
|
|
|
448
|
0
|
|
|
|
|
0
|
(@_); |
449
|
|
|
|
|
|
|
}; |
450
|
0
|
|
|
|
|
0
|
$$__REF__ > $_[1]; |
451
|
|
|
|
|
|
|
} |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
=head2 C<< le( $number, $num ) >> |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
Additional arguments: B<< Num >>. |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
Returns C<< $number <= $num >>. |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
=cut |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
sub le { |
462
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
465
|
0
|
|
|
|
|
0
|
@_ = do { |
466
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
467
|
|
|
|
|
|
|
|
468
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
469
|
|
|
|
|
|
|
or Hydrogen::croak( |
470
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
471
|
|
|
|
|
|
|
"le", scalar(@_), "expected exactly 2 parameters" ); |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
# Parameter $_[0] (type: Num) |
474
|
|
|
|
|
|
|
( |
475
|
0
|
0
|
|
|
|
0
|
do { |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
478
|
3
|
|
|
3
|
|
30
|
use Scalar::Util (); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
252
|
|
479
|
0
|
0
|
0
|
|
|
0
|
defined( $_[0] ) |
480
|
|
|
|
|
|
|
&& !ref( $_[0] ) |
481
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[0] ); |
482
|
|
|
|
|
|
|
} |
483
|
|
|
|
|
|
|
) |
484
|
|
|
|
|
|
|
or Hydrogen::croak( |
485
|
|
|
|
|
|
|
"Type check failed in signature for le: %s should be %s", |
486
|
|
|
|
|
|
|
"\$_[0]", "Num" ); |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
# Parameter $_[1] (type: Num) |
489
|
|
|
|
|
|
|
( |
490
|
0
|
0
|
|
|
|
0
|
do { |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
493
|
3
|
|
|
3
|
|
43
|
use Scalar::Util (); |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
492
|
|
494
|
0
|
0
|
0
|
|
|
0
|
defined( $_[1] ) |
495
|
|
|
|
|
|
|
&& !ref( $_[1] ) |
496
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[1] ); |
497
|
|
|
|
|
|
|
} |
498
|
|
|
|
|
|
|
) |
499
|
|
|
|
|
|
|
or Hydrogen::croak( |
500
|
|
|
|
|
|
|
"Type check failed in signature for le: %s should be %s", |
501
|
|
|
|
|
|
|
"\$_[1]", "Num" ); |
502
|
|
|
|
|
|
|
|
503
|
0
|
|
|
|
|
0
|
(@_); |
504
|
|
|
|
|
|
|
}; |
505
|
0
|
|
|
|
|
0
|
$$__REF__ <= $_[1]; |
506
|
|
|
|
|
|
|
} |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
=head2 C<< lt( $number, $num ) >> |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
Additional arguments: B<< Num >>. |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
Returns C<< $number < $num >>. |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
=cut |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
sub lt { |
517
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
520
|
0
|
|
|
|
|
0
|
@_ = do { |
521
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
522
|
|
|
|
|
|
|
|
523
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
524
|
|
|
|
|
|
|
or Hydrogen::croak( |
525
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
526
|
|
|
|
|
|
|
"lt", scalar(@_), "expected exactly 2 parameters" ); |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
# Parameter $_[0] (type: Num) |
529
|
|
|
|
|
|
|
( |
530
|
0
|
0
|
|
|
|
0
|
do { |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
533
|
3
|
|
|
3
|
|
19
|
use Scalar::Util (); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
238
|
|
534
|
0
|
0
|
0
|
|
|
0
|
defined( $_[0] ) |
535
|
|
|
|
|
|
|
&& !ref( $_[0] ) |
536
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[0] ); |
537
|
|
|
|
|
|
|
} |
538
|
|
|
|
|
|
|
) |
539
|
|
|
|
|
|
|
or Hydrogen::croak( |
540
|
|
|
|
|
|
|
"Type check failed in signature for lt: %s should be %s", |
541
|
|
|
|
|
|
|
"\$_[0]", "Num" ); |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
# Parameter $_[1] (type: Num) |
544
|
|
|
|
|
|
|
( |
545
|
0
|
0
|
|
|
|
0
|
do { |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
548
|
3
|
|
|
3
|
|
19
|
use Scalar::Util (); |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
504
|
|
549
|
0
|
0
|
0
|
|
|
0
|
defined( $_[1] ) |
550
|
|
|
|
|
|
|
&& !ref( $_[1] ) |
551
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[1] ); |
552
|
|
|
|
|
|
|
} |
553
|
|
|
|
|
|
|
) |
554
|
|
|
|
|
|
|
or Hydrogen::croak( |
555
|
|
|
|
|
|
|
"Type check failed in signature for lt: %s should be %s", |
556
|
|
|
|
|
|
|
"\$_[1]", "Num" ); |
557
|
|
|
|
|
|
|
|
558
|
0
|
|
|
|
|
0
|
(@_); |
559
|
|
|
|
|
|
|
}; |
560
|
0
|
|
|
|
|
0
|
$$__REF__ < $_[1]; |
561
|
|
|
|
|
|
|
} |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
=head2 C<< mod( $number, $divisor ) >> |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
Additional arguments: B<< Num >>. |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
Finds the current number modulo a divisor, updating the original value. |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
=cut |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
sub mod { |
572
|
1
|
|
|
1
|
1
|
8135
|
my $__REF__ = \$_[0]; |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
575
|
1
|
|
|
|
|
3
|
@_ = do { |
576
|
1
|
|
|
|
|
2
|
my ( %tmp, $tmp ); |
577
|
|
|
|
|
|
|
|
578
|
1
|
50
|
|
|
|
5
|
@_ == 2 |
579
|
|
|
|
|
|
|
or Hydrogen::croak( |
580
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
581
|
|
|
|
|
|
|
"mod", scalar(@_), "expected exactly 2 parameters" ); |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
# Parameter $_[0] (type: Num) |
584
|
|
|
|
|
|
|
( |
585
|
1
|
50
|
|
|
|
2
|
do { |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
588
|
3
|
|
|
3
|
|
21
|
use Scalar::Util (); |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
234
|
|
589
|
1
|
50
|
33
|
|
|
13
|
defined( $_[0] ) |
590
|
|
|
|
|
|
|
&& !ref( $_[0] ) |
591
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[0] ); |
592
|
|
|
|
|
|
|
} |
593
|
|
|
|
|
|
|
) |
594
|
|
|
|
|
|
|
or Hydrogen::croak( |
595
|
|
|
|
|
|
|
"Type check failed in signature for mod: %s should be %s", |
596
|
|
|
|
|
|
|
"\$_[0]", "Num" ); |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
# Parameter $_[1] (type: Num) |
599
|
|
|
|
|
|
|
( |
600
|
1
|
50
|
|
|
|
3
|
do { |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
603
|
3
|
|
|
3
|
|
19
|
use Scalar::Util (); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
301
|
|
604
|
1
|
50
|
33
|
|
|
12
|
defined( $_[1] ) |
605
|
|
|
|
|
|
|
&& !ref( $_[1] ) |
606
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[1] ); |
607
|
|
|
|
|
|
|
} |
608
|
|
|
|
|
|
|
) |
609
|
|
|
|
|
|
|
or Hydrogen::croak( |
610
|
|
|
|
|
|
|
"Type check failed in signature for mod: %s should be %s", |
611
|
|
|
|
|
|
|
"\$_[1]", "Num" ); |
612
|
|
|
|
|
|
|
|
613
|
1
|
|
|
|
|
5
|
(@_); |
614
|
|
|
|
|
|
|
}; |
615
|
|
|
|
|
|
|
( |
616
|
1
|
|
|
|
|
2
|
${$__REF__} = do { |
|
1
|
|
|
|
|
3
|
|
617
|
1
|
|
|
|
|
5
|
my $shv_final_unchecked = $$__REF__ % $_[1]; |
618
|
1
|
|
|
|
|
12
|
do { |
619
|
|
|
|
|
|
|
( |
620
|
1
|
50
|
|
|
|
3
|
do { |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
623
|
3
|
|
|
3
|
|
20
|
use Scalar::Util (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
440
|
|
624
|
1
|
50
|
33
|
|
|
12
|
defined($shv_final_unchecked) |
625
|
|
|
|
|
|
|
&& !ref($shv_final_unchecked) |
626
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( |
627
|
|
|
|
|
|
|
$shv_final_unchecked); |
628
|
|
|
|
|
|
|
} |
629
|
|
|
|
|
|
|
) |
630
|
|
|
|
|
|
|
or Hydrogen::croak( |
631
|
|
|
|
|
|
|
"Type check failed for mod: expected %s, got value %s", |
632
|
|
|
|
|
|
|
"Num", $shv_final_unchecked ); |
633
|
1
|
|
|
|
|
4
|
$shv_final_unchecked; |
634
|
|
|
|
|
|
|
}; |
635
|
|
|
|
|
|
|
} |
636
|
|
|
|
|
|
|
); |
637
|
|
|
|
|
|
|
} |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
=head2 C<< mul( $number, $factor ) >> |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
Additional arguments: B<< Num >>. |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
Multiplies the existing number by a number, updating the original value. |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
=cut |
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
sub mul { |
648
|
1
|
|
|
1
|
1
|
2777
|
my $__REF__ = \$_[0]; |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
651
|
1
|
|
|
|
|
2
|
@_ = do { |
652
|
1
|
|
|
|
|
3
|
my ( %tmp, $tmp ); |
653
|
|
|
|
|
|
|
|
654
|
1
|
50
|
|
|
|
5
|
@_ == 2 |
655
|
|
|
|
|
|
|
or Hydrogen::croak( |
656
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
657
|
|
|
|
|
|
|
"mul", scalar(@_), "expected exactly 2 parameters" ); |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
# Parameter $_[0] (type: Num) |
660
|
|
|
|
|
|
|
( |
661
|
1
|
50
|
|
|
|
2
|
do { |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
664
|
3
|
|
|
3
|
|
20
|
use Scalar::Util (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
267
|
|
665
|
1
|
50
|
33
|
|
|
12
|
defined( $_[0] ) |
666
|
|
|
|
|
|
|
&& !ref( $_[0] ) |
667
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[0] ); |
668
|
|
|
|
|
|
|
} |
669
|
|
|
|
|
|
|
) |
670
|
|
|
|
|
|
|
or Hydrogen::croak( |
671
|
|
|
|
|
|
|
"Type check failed in signature for mul: %s should be %s", |
672
|
|
|
|
|
|
|
"\$_[0]", "Num" ); |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
# Parameter $_[1] (type: Num) |
675
|
|
|
|
|
|
|
( |
676
|
1
|
50
|
|
|
|
3
|
do { |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
679
|
3
|
|
|
3
|
|
20
|
use Scalar::Util (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
351
|
|
680
|
1
|
50
|
33
|
|
|
11
|
defined( $_[1] ) |
681
|
|
|
|
|
|
|
&& !ref( $_[1] ) |
682
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[1] ); |
683
|
|
|
|
|
|
|
} |
684
|
|
|
|
|
|
|
) |
685
|
|
|
|
|
|
|
or Hydrogen::croak( |
686
|
|
|
|
|
|
|
"Type check failed in signature for mul: %s should be %s", |
687
|
|
|
|
|
|
|
"\$_[1]", "Num" ); |
688
|
|
|
|
|
|
|
|
689
|
1
|
|
|
|
|
4
|
(@_); |
690
|
|
|
|
|
|
|
}; |
691
|
|
|
|
|
|
|
( |
692
|
1
|
|
|
|
|
2
|
${$__REF__} = do { |
|
1
|
|
|
|
|
4
|
|
693
|
1
|
|
|
|
|
3
|
my $shv_final_unchecked = $$__REF__ * $_[1]; |
694
|
1
|
|
|
|
|
3
|
do { |
695
|
|
|
|
|
|
|
( |
696
|
1
|
50
|
|
|
|
13
|
do { |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
699
|
3
|
|
|
3
|
|
26
|
use Scalar::Util (); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
406
|
|
700
|
1
|
50
|
33
|
|
|
12
|
defined($shv_final_unchecked) |
701
|
|
|
|
|
|
|
&& !ref($shv_final_unchecked) |
702
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( |
703
|
|
|
|
|
|
|
$shv_final_unchecked); |
704
|
|
|
|
|
|
|
} |
705
|
|
|
|
|
|
|
) |
706
|
|
|
|
|
|
|
or Hydrogen::croak( |
707
|
|
|
|
|
|
|
"Type check failed for mul: expected %s, got value %s", |
708
|
|
|
|
|
|
|
"Num", $shv_final_unchecked ); |
709
|
1
|
|
|
|
|
3
|
$shv_final_unchecked; |
710
|
|
|
|
|
|
|
}; |
711
|
|
|
|
|
|
|
} |
712
|
|
|
|
|
|
|
); |
713
|
|
|
|
|
|
|
} |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
=head2 C<< ne( $number, $num ) >> |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
Additional arguments: B<< Num >>. |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
Returns C<< $number != $num >>. |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
=cut |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
sub ne { |
724
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
727
|
0
|
|
|
|
|
0
|
@_ = do { |
728
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
729
|
|
|
|
|
|
|
|
730
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
731
|
|
|
|
|
|
|
or Hydrogen::croak( |
732
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
733
|
|
|
|
|
|
|
"ne", scalar(@_), "expected exactly 2 parameters" ); |
734
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
# Parameter $_[0] (type: Num) |
736
|
|
|
|
|
|
|
( |
737
|
0
|
0
|
|
|
|
0
|
do { |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
740
|
3
|
|
|
3
|
|
22
|
use Scalar::Util (); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
208
|
|
741
|
0
|
0
|
0
|
|
|
0
|
defined( $_[0] ) |
742
|
|
|
|
|
|
|
&& !ref( $_[0] ) |
743
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[0] ); |
744
|
|
|
|
|
|
|
} |
745
|
|
|
|
|
|
|
) |
746
|
|
|
|
|
|
|
or Hydrogen::croak( |
747
|
|
|
|
|
|
|
"Type check failed in signature for ne: %s should be %s", |
748
|
|
|
|
|
|
|
"\$_[0]", "Num" ); |
749
|
|
|
|
|
|
|
|
750
|
|
|
|
|
|
|
# Parameter $_[1] (type: Num) |
751
|
|
|
|
|
|
|
( |
752
|
0
|
0
|
|
|
|
0
|
do { |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
755
|
3
|
|
|
3
|
|
17
|
use Scalar::Util (); |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
501
|
|
756
|
0
|
0
|
0
|
|
|
0
|
defined( $_[1] ) |
757
|
|
|
|
|
|
|
&& !ref( $_[1] ) |
758
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[1] ); |
759
|
|
|
|
|
|
|
} |
760
|
|
|
|
|
|
|
) |
761
|
|
|
|
|
|
|
or Hydrogen::croak( |
762
|
|
|
|
|
|
|
"Type check failed in signature for ne: %s should be %s", |
763
|
|
|
|
|
|
|
"\$_[1]", "Num" ); |
764
|
|
|
|
|
|
|
|
765
|
0
|
|
|
|
|
0
|
(@_); |
766
|
|
|
|
|
|
|
}; |
767
|
0
|
|
|
|
|
0
|
$$__REF__ != $_[1]; |
768
|
|
|
|
|
|
|
} |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
=head2 C<< set( $number, $value ) >> |
771
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
Additional arguments: B<< Num >>. |
773
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
Sets the number to a new value. |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
=cut |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
sub set { |
779
|
1
|
|
|
1
|
1
|
4993
|
my $__REF__ = \$_[0]; |
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
782
|
1
|
|
|
|
|
3
|
@_ = do { |
783
|
1
|
|
|
|
|
2
|
my ( %tmp, $tmp ); |
784
|
|
|
|
|
|
|
|
785
|
1
|
50
|
|
|
|
5
|
@_ == 2 |
786
|
|
|
|
|
|
|
or Hydrogen::croak( |
787
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
788
|
|
|
|
|
|
|
"set", scalar(@_), "expected exactly 2 parameters" ); |
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
# Parameter $_[0] (type: Num) |
791
|
|
|
|
|
|
|
( |
792
|
1
|
50
|
|
|
|
2
|
do { |
793
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
795
|
3
|
|
|
3
|
|
20
|
use Scalar::Util (); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
230
|
|
796
|
1
|
50
|
33
|
|
|
15
|
defined( $_[0] ) |
797
|
|
|
|
|
|
|
&& !ref( $_[0] ) |
798
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[0] ); |
799
|
|
|
|
|
|
|
} |
800
|
|
|
|
|
|
|
) |
801
|
|
|
|
|
|
|
or Hydrogen::croak( |
802
|
|
|
|
|
|
|
"Type check failed in signature for set: %s should be %s", |
803
|
|
|
|
|
|
|
"\$_[0]", "Num" ); |
804
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
# Parameter $_[1] (type: Num) |
806
|
|
|
|
|
|
|
( |
807
|
1
|
50
|
|
|
|
2
|
do { |
808
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
810
|
3
|
|
|
3
|
|
19
|
use Scalar::Util (); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
313
|
|
811
|
1
|
50
|
33
|
|
|
10
|
defined( $_[1] ) |
812
|
|
|
|
|
|
|
&& !ref( $_[1] ) |
813
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[1] ); |
814
|
|
|
|
|
|
|
} |
815
|
|
|
|
|
|
|
) |
816
|
|
|
|
|
|
|
or Hydrogen::croak( |
817
|
|
|
|
|
|
|
"Type check failed in signature for set: %s should be %s", |
818
|
|
|
|
|
|
|
"\$_[1]", "Num" ); |
819
|
|
|
|
|
|
|
|
820
|
1
|
|
|
|
|
4
|
(@_); |
821
|
|
|
|
|
|
|
}; |
822
|
|
|
|
|
|
|
( |
823
|
1
|
|
|
|
|
2
|
${$__REF__} = do { |
|
1
|
|
|
|
|
4
|
|
824
|
1
|
|
|
|
|
3
|
my $shv_final_unchecked = $_[1]; |
825
|
1
|
|
|
|
|
13
|
do { |
826
|
|
|
|
|
|
|
( |
827
|
1
|
50
|
|
|
|
6
|
do { |
828
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
830
|
3
|
|
|
3
|
|
19
|
use Scalar::Util (); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
425
|
|
831
|
1
|
50
|
33
|
|
|
14
|
defined($shv_final_unchecked) |
832
|
|
|
|
|
|
|
&& !ref($shv_final_unchecked) |
833
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( |
834
|
|
|
|
|
|
|
$shv_final_unchecked); |
835
|
|
|
|
|
|
|
} |
836
|
|
|
|
|
|
|
) |
837
|
|
|
|
|
|
|
or Hydrogen::croak( |
838
|
|
|
|
|
|
|
"Type check failed for set: expected %s, got value %s", |
839
|
|
|
|
|
|
|
"Num", $shv_final_unchecked ); |
840
|
1
|
|
|
|
|
3
|
$shv_final_unchecked; |
841
|
|
|
|
|
|
|
}; |
842
|
|
|
|
|
|
|
} |
843
|
|
|
|
|
|
|
); |
844
|
|
|
|
|
|
|
} |
845
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
=head2 C<< sub( $number, $subtrahend ) >> |
847
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
Additional arguments: B<< Num >>. |
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
Subtracts a number from the existing number, updating the original value. |
851
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
=cut |
853
|
|
|
|
|
|
|
|
854
|
|
|
|
|
|
|
sub sub { |
855
|
1
|
|
|
1
|
1
|
2764
|
my $__REF__ = \$_[0]; |
856
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
858
|
1
|
|
|
|
|
2
|
@_ = do { |
859
|
1
|
|
|
|
|
3
|
my ( %tmp, $tmp ); |
860
|
|
|
|
|
|
|
|
861
|
1
|
50
|
|
|
|
5
|
@_ == 2 |
862
|
|
|
|
|
|
|
or Hydrogen::croak( |
863
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
864
|
|
|
|
|
|
|
"sub", scalar(@_), "expected exactly 2 parameters" ); |
865
|
|
|
|
|
|
|
|
866
|
|
|
|
|
|
|
# Parameter $_[0] (type: Num) |
867
|
|
|
|
|
|
|
( |
868
|
1
|
50
|
|
|
|
3
|
do { |
869
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
871
|
3
|
|
|
3
|
|
23
|
use Scalar::Util (); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
213
|
|
872
|
1
|
50
|
33
|
|
|
18
|
defined( $_[0] ) |
873
|
|
|
|
|
|
|
&& !ref( $_[0] ) |
874
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[0] ); |
875
|
|
|
|
|
|
|
} |
876
|
|
|
|
|
|
|
) |
877
|
|
|
|
|
|
|
or Hydrogen::croak( |
878
|
|
|
|
|
|
|
"Type check failed in signature for sub: %s should be %s", |
879
|
|
|
|
|
|
|
"\$_[0]", "Num" ); |
880
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
# Parameter $_[1] (type: Num) |
882
|
|
|
|
|
|
|
( |
883
|
1
|
50
|
|
|
|
3
|
do { |
884
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
886
|
3
|
|
|
3
|
|
20
|
use Scalar::Util (); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
315
|
|
887
|
1
|
50
|
33
|
|
|
9
|
defined( $_[1] ) |
888
|
|
|
|
|
|
|
&& !ref( $_[1] ) |
889
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( $_[1] ); |
890
|
|
|
|
|
|
|
} |
891
|
|
|
|
|
|
|
) |
892
|
|
|
|
|
|
|
or Hydrogen::croak( |
893
|
|
|
|
|
|
|
"Type check failed in signature for sub: %s should be %s", |
894
|
|
|
|
|
|
|
"\$_[1]", "Num" ); |
895
|
|
|
|
|
|
|
|
896
|
1
|
|
|
|
|
4
|
(@_); |
897
|
|
|
|
|
|
|
}; |
898
|
|
|
|
|
|
|
( |
899
|
1
|
|
|
|
|
2
|
${$__REF__} = do { |
|
1
|
|
|
|
|
3
|
|
900
|
1
|
|
|
|
|
4
|
my $shv_final_unchecked = $$__REF__ - $_[1]; |
901
|
1
|
|
|
|
|
2
|
do { |
902
|
|
|
|
|
|
|
( |
903
|
1
|
50
|
|
|
|
2
|
do { |
904
|
|
|
|
|
|
|
|
905
|
|
|
|
|
|
|
package Hydrogen::Number::__SANDBOX__; |
906
|
3
|
|
|
3
|
|
19
|
use Scalar::Util (); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
281
|
|
907
|
1
|
50
|
33
|
|
|
9
|
defined($shv_final_unchecked) |
908
|
|
|
|
|
|
|
&& !ref($shv_final_unchecked) |
909
|
|
|
|
|
|
|
&& Scalar::Util::looks_like_number( |
910
|
|
|
|
|
|
|
$shv_final_unchecked); |
911
|
|
|
|
|
|
|
} |
912
|
|
|
|
|
|
|
) |
913
|
|
|
|
|
|
|
or Hydrogen::croak( |
914
|
|
|
|
|
|
|
"Type check failed for sub: expected %s, got value %s", |
915
|
|
|
|
|
|
|
"Num", $shv_final_unchecked ); |
916
|
1
|
|
|
|
|
3
|
$shv_final_unchecked; |
917
|
|
|
|
|
|
|
}; |
918
|
|
|
|
|
|
|
} |
919
|
|
|
|
|
|
|
); |
920
|
|
|
|
|
|
|
} |
921
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
1; |
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
=head1 EXPORT |
925
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
No functions are exported by this module by default. To import them all (this is usually a bad idea), use: |
927
|
|
|
|
|
|
|
|
928
|
|
|
|
|
|
|
use Hydrogen::Number -all; |
929
|
|
|
|
|
|
|
|
930
|
|
|
|
|
|
|
To import a particular function, use: |
931
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
use Hydrogen::Number 'cmp'; |
933
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
To rename functions: |
935
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
use Hydrogen::Number 'cmp' => { -as => 'myfunc' }; |
937
|
|
|
|
|
|
|
|
938
|
|
|
|
|
|
|
On Perl 5.37.2+, you can import lexically: |
939
|
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
use Hydrogen::Number -lexical, 'cmp'; |
941
|
|
|
|
|
|
|
|
942
|
|
|
|
|
|
|
See L for more hints on importing. |
943
|
|
|
|
|
|
|
|
944
|
|
|
|
|
|
|
=head1 BUGS |
945
|
|
|
|
|
|
|
|
946
|
|
|
|
|
|
|
Please report any bugs to |
947
|
|
|
|
|
|
|
L. |
948
|
|
|
|
|
|
|
|
949
|
|
|
|
|
|
|
=head1 SEE ALSO |
950
|
|
|
|
|
|
|
|
951
|
|
|
|
|
|
|
L, |
952
|
|
|
|
|
|
|
L, |
953
|
|
|
|
|
|
|
L, |
954
|
|
|
|
|
|
|
L. |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
=head1 AUTHOR |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
Toby Inkster Etobyink@cpan.orgE. |
959
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Toby Inkster. |
963
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
965
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
966
|
|
|
|
|
|
|
|
967
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
968
|
|
|
|
|
|
|
|
969
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
970
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
971
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
972
|
|
|
|
|
|
|
|