Lines Matching refs:LIB

30 my $LIB = 'Math::BigInt::Calc';
35 my $x = $LIB->_new("123");
36 my $y = $LIB->_new("321");
38 is($LIB->_str($x), 123, qq|$LIB->_str(\$x) = 123|);
39 is($LIB->_str($y), 321, qq|$LIB->_str(\$y) = 321|);
44 is($LIB->_str($LIB->_add($x, $y)), 444,
45 qq|$LIB->_str($LIB->_add(\$x, \$y)) = 444|);
46 is($LIB->_str($LIB->_sub($x, $y)), 123,
47 qq|$LIB->_str($LIB->_sub(\$x, \$y)) = 123|);
48 is($LIB->_str($LIB->_mul($x, $y)), 39483,
49 qq|$LIB->_str($LIB->_mul(\$x, \$y)) = 39483|);
50 is($LIB->_str($LIB->_div($x, $y)), 123,
51 qq|$LIB->_str($LIB->_div(\$x, \$y)) = 123|);
57 is($LIB->_str($LIB->_mul($x, $y)), 39483,
58 qq|$LIB->_str($LIB->_mul(\$x, \$y)) = 39483|);
59 is($LIB->_str($x), 39483,
60 qq|$LIB->_str(\$x) = 39483|);
61 is($LIB->_str($y), 321,
62 qq|$LIB->_str(\$y) = 321|);
64 is($LIB->_str($LIB->_div($x, $y)), 123,
65 qq|$LIB->_str($LIB->_div(\$x, \$y)) = 123|);
66 is($LIB->_str($x), 123,
67 qq|$LIB->_str(\$x) = 123|);
68 is($LIB->_str($y), 321,
69 qq|$LIB->_str(\$y) = 321|);
71 $x = $LIB->_new("39483");
72 my ($x1, $r1) = $LIB->_div($x, $y);
74 $LIB->_inc($x1);
76 is($LIB->_str($r1), "0", qq|$LIB->_str(\$r1) = "0"|);
78 $x = $LIB->_new("39483"); # reset
82 my $z = $LIB->_new("2");
83 is($LIB->_str($LIB->_add($x, $z)), 39485,
84 qq|$LIB->_str($LIB->_add(\$x, \$z)) = 39485|);
85 my ($re, $rr) = $LIB->_div($x, $y);
87 is($LIB->_str($re), 123, qq|$LIB->_str(\$re) = 123|);
88 is($LIB->_str($rr), 2, qq|$LIB->_str(\$rr) = 2|);
92 ok(! $LIB->_is_zero($x), qq|$LIB->_is_zero(\$x)|);
93 ok(! $LIB->_is_one($x), qq|$LIB->_is_one(\$x)|);
95 is($LIB->_str($LIB->_zero()), "0", qq|$LIB->_str($LIB->_zero()) = "0"|);
96 is($LIB->_str($LIB->_one()), "1", qq|$LIB->_str($LIB->_one()) = "1"|);
100 is($LIB->_str($LIB->_two()), "2", qq|$LIB->_str($LIB->_two()) = "2"|);
101 is($LIB->_str($LIB->_ten()), "10", qq|$LIB->_str($LIB->_ten()) = "10"|);
103 ok(! $LIB->_is_ten($LIB->_two()), qq|$LIB->_is_ten($LIB->_two()) is false|);
104 ok( $LIB->_is_two($LIB->_two()), qq|$LIB->_is_two($LIB->_two()) is true|);
105 ok( $LIB->_is_ten($LIB->_ten()), qq|$LIB->_is_ten($LIB->_ten()) is true|);
106 ok(! $LIB->_is_two($LIB->_ten()), qq|$LIB->_is_two($LIB->_ten()) is false|);
108 ok( $LIB->_is_one($LIB->_one()), qq|$LIB->_is_one($LIB->_one()) is true|);
109 ok(! $LIB->_is_one($LIB->_two()), qq|$LIB->_is_one($LIB->_two()) is false|);
110 ok(! $LIB->_is_one($LIB->_ten()), qq|$LIB->_is_one($LIB->_ten()) is false|);
112 ok(! $LIB->_is_one($LIB->_zero()), qq/$LIB->_is_one($LIB->_zero()) is false/);
113 ok( $LIB->_is_zero($LIB->_zero()), qq|$LIB->_is_zero($LIB->_zero()) is true|);
114 ok(! $LIB->_is_zero($LIB->_one()), qq/$LIB->_is_zero($LIB->_one()) is false/);
118 ok( $LIB->_is_odd($LIB->_one()), qq/$LIB->_is_odd($LIB->_one()) is true/);
119 ok(! $LIB->_is_odd($LIB->_zero()), qq/$LIB->_is_odd($LIB->_zero()) is false/);
120 ok(! $LIB->_is_even($LIB->_one()), qq/$LIB->_is_even($LIB->_one()) is false/);
121 ok( $LIB->_is_even($LIB->_zero()), qq/$LIB->_is_even($LIB->_zero()) is true/);
126 $x = $LIB->_new("1");
127 is($LIB->$method($x), 1, qq|$LIB->$method(\$x) = 1|);
128 $x = $LIB->_new("12");
129 is($LIB->$method($x), 2, qq|$LIB->$method(\$x) = 2|);
130 $x = $LIB->_new("123");
131 is($LIB->$method($x), 3, qq|$LIB->$method(\$x) = 3|);
132 $x = $LIB->_new("1234");
133 is($LIB->$method($x), 4, qq|$LIB->$method(\$x) = 4|);
134 $x = $LIB->_new("12345");
135 is($LIB->$method($x), 5, qq|$LIB->$method(\$x) = 5|);
136 $x = $LIB->_new("123456");
137 is($LIB->$method($x), 6, qq|$LIB->$method(\$x) = 6|);
138 $x = $LIB->_new("1234567");
139 is($LIB->$method($x), 7, qq|$LIB->$method(\$x) = 7|);
140 $x = $LIB->_new("12345678");
141 is($LIB->$method($x), 8, qq|$LIB->$method(\$x) = 8|);
142 $x = $LIB->_new("123456789");
143 is($LIB->$method($x), 9, qq|$LIB->$method(\$x) = 9|);
145 $x = $LIB->_new("8");
146 is($LIB->$method($x), 1, qq|$LIB->$method(\$x) = 1|);
147 $x = $LIB->_new("21");
148 is($LIB->$method($x), 2, qq|$LIB->$method(\$x) = 2|);
149 $x = $LIB->_new("321");
150 is($LIB->$method($x), 3, qq|$LIB->$method(\$x) = 3|);
151 $x = $LIB->_new("4321");
152 is($LIB->$method($x), 4, qq|$LIB->$method(\$x) = 4|);
153 $x = $LIB->_new("54321");
154 is($LIB->$method($x), 5, qq|$LIB->$method(\$x) = 5|);
155 $x = $LIB->_new("654321");
156 is($LIB->$method($x), 6, qq|$LIB->$method(\$x) = 6|);
157 $x = $LIB->_new("7654321");
158 is($LIB->$method($x), 7, qq|$LIB->$method(\$x) = 7|);
159 $x = $LIB->_new("87654321");
160 is($LIB->$method($x), 8, qq|$LIB->$method(\$x) = 8|);
161 $x = $LIB->_new("987654321");
162 is($LIB->$method($x), 9, qq|$LIB->$method(\$x) = 9|);
164 $x = $LIB->_new("0");
165 is($LIB->$method($x), 1, qq|$LIB->$method(\$x) = 1|);
166 $x = $LIB->_new("20");
167 is($LIB->$method($x), 2, qq|$LIB->$method(\$x) = 2|);
168 $x = $LIB->_new("320");
169 is($LIB->$method($x), 3, qq|$LIB->$method(\$x) = 3|);
170 $x = $LIB->_new("4320");
171 is($LIB->$method($x), 4, qq|$LIB->$method(\$x) = 4|);
172 $x = $LIB->_new("54320");
173 is($LIB->$method($x), 5, qq|$LIB->$method(\$x) = 5|);
174 $x = $LIB->_new("654320");
175 is($LIB->$method($x), 6, qq|$LIB->$method(\$x) = 6|);
176 $x = $LIB->_new("7654320");
177 is($LIB->$method($x), 7, qq|$LIB->$method(\$x) = 7|);
178 $x = $LIB->_new("87654320");
179 is($LIB->$method($x), 8, qq|$LIB->$method(\$x) = 8|);
180 $x = $LIB->_new("987654320");
181 is($LIB->$method($x), 9, qq|$LIB->$method(\$x) = 9|);
185 $x = $LIB->_new($a);
186 is($LIB->_len($x), $i, qq|$LIB->_len(\$x) = $i|);
192 $x = $LIB->_new("123456789");
193 is($LIB->_digit($x, 0), 9, qq|$LIB->_digit(\$x, 0) = 9|);
194 is($LIB->_digit($x, 1), 8, qq|$LIB->_digit(\$x, 1) = 8|);
195 is($LIB->_digit($x, 2), 7, qq|$LIB->_digit(\$x, 2) = 7|);
196 is($LIB->_digit($x, 8), 1, qq|$LIB->_digit(\$x, 8) = 1|);
197 is($LIB->_digit($x, 9), 0, qq|$LIB->_digit(\$x, 9) = 0|);
198 is($LIB->_digit($x, -1), 1, qq|$LIB->_digit(\$x, -1) = 1|);
199 is($LIB->_digit($x, -2), 2, qq|$LIB->_digit(\$x, -2) = 2|);
200 is($LIB->_digit($x, -3), 3, qq|$LIB->_digit(\$x, -3) = 3|);
201 is($LIB->_digit($x, -9), 9, qq|$LIB->_digit(\$x, -9) = 9|);
202 is($LIB->_digit($x, -10), 0, qq|$LIB->_digit(\$x, -10) = 0|);
207 $x = $LIB->_new("$_");
208 is($LIB->_str($LIB->_copy($x)), "$_",
209 qq|$LIB->_str($LIB->_copy(\$x)) = "$_"|);
210 is($LIB->_str($x), "$_", # did _copy destroy original x?
211 qq|$LIB->_str(\$x) = "$_"|);
216 $x = $LIB->_new("1256000000");
217 is($LIB->_zeros($x), 6, qq|$LIB->_zeros(\$x) = 6|);
219 $x = $LIB->_new("152");
220 is($LIB->_zeros($x), 0, qq|$LIB->_zeros(\$x) = 0|);
222 $x = $LIB->_new("123000");
223 is($LIB->_zeros($x), 3, qq|$LIB->_zeros(\$x) = 3|);
225 $x = $LIB->_new("0");
226 is($LIB->_zeros($x), 0, qq|$LIB->_zeros(\$x) = 0|);
230 $x = $LIB->_new("10");
231 $y = $LIB->_new("3");
232 is($LIB->_str($LIB->_lsft($x, $y, 10)), 10000,
233 qq|$LIB->_str($LIB->_lsft(\$x, \$y, 10)) = 10000|);
235 $x = $LIB->_new("20");
236 $y = $LIB->_new("3");
237 is($LIB->_str($LIB->_lsft($x, $y, 10)), 20000,
238 qq|$LIB->_str($LIB->_lsft(\$x, \$y, 10)) = 20000|);
240 $x = $LIB->_new("128");
241 $y = $LIB->_new("4");
242 is($LIB->_str($LIB->_lsft($x, $y, 2)), 128 << 4,
243 qq|$LIB->_str($LIB->_lsft(\$x, \$y, 2)) = 128 << 4|);
245 $x = $LIB->_new("1000");
246 $y = $LIB->_new("3");
247 is($LIB->_str($LIB->_rsft($x, $y, 10)), 1,
248 qq|$LIB->_str($LIB->_rsft(\$x, \$y, 10)) = 1|);
250 $x = $LIB->_new("20000");
251 $y = $LIB->_new("3");
252 is($LIB->_str($LIB->_rsft($x, $y, 10)), 20,
253 qq|$LIB->_str($LIB->_rsft(\$x, \$y, 10)) = 20|);
255 $x = $LIB->_new("256");
256 $y = $LIB->_new("4");
257 is($LIB->_str($LIB->_rsft($x, $y, 2)), 256 >> 4,
258 qq|$LIB->_str($LIB->_rsft(\$x, \$y, 2)) = 256 >> 4|);
260 $x = $LIB->_new("6411906467305339182857313397200584952398");
261 $y = $LIB->_new("45");
262 is($LIB->_str($LIB->_rsft($x, $y, 10)), 0,
263 qq|$LIB->_str($LIB->_rsft(\$x, \$y, 10)) = 0|);
272 my $xobj = $LIB->_new($xstr);
273 my $nobj = $LIB->_new($nstr);
274 my $bobj = $LIB->_new($bstr);
276 is($LIB->_str($LIB->_lsft($xobj, $nobj, $bobj)), $expected,
277 qq|$LIB->_str($LIB->_lsft($LIB->_new("$xstr"), |
278 . qq|$LIB->_new("$nstr"), |
279 . qq|$LIB->_new("$bstr")))|);
280 is($LIB->_str($nobj), $nstr, q|$n is unmodified|);
281 is($LIB->_str($bobj), $bstr, q|$b is unmodified|);
288 $x = $LIB->_new("123456789");
289 $y = $LIB->_new("987654321");
290 is($LIB->_acmp($x, $y), -1, qq|$LIB->_acmp(\$x, \$y) = -1|);
291 is($LIB->_acmp($y, $x), 1, qq|$LIB->_acmp(\$y, \$x) = 1|);
292 is($LIB->_acmp($x, $x), 0, qq|$LIB->_acmp(\$x, \$x) = 0|);
293 is($LIB->_acmp($y, $y), 0, qq|$LIB->_acmp(\$y, \$y) = 0|);
294 $x = $LIB->_new("12");
295 $y = $LIB->_new("12");
296 is($LIB->_acmp($x, $y), 0, qq|$LIB->_acmp(\$x, \$y) = 0|);
297 $x = $LIB->_new("21");
298 is($LIB->_acmp($x, $y), 1, qq|$LIB->_acmp(\$x, \$y) = 1|);
299 is($LIB->_acmp($y, $x), -1, qq|$LIB->_acmp(\$y, \$x) = -1|);
300 $x = $LIB->_new("123456789");
301 $y = $LIB->_new("1987654321");
302 is($LIB->_acmp($x, $y), -1, qq|$LIB->_acmp(\$x, \$y) = -1|);
303 is($LIB->_acmp($y, $x), +1, qq|$LIB->_acmp(\$y, \$x) = +1|);
305 $x = $LIB->_new("1234567890123456789");
306 $y = $LIB->_new("987654321012345678");
307 is($LIB->_acmp($x, $y), 1, qq|$LIB->_acmp(\$x, \$y) = 1|);
308 is($LIB->_acmp($y, $x), -1, qq|$LIB->_acmp(\$y, \$x) = -1|);
309 is($LIB->_acmp($x, $x), 0, qq|$LIB->_acmp(\$x, \$x) = 0|);
310 is($LIB->_acmp($y, $y), 0, qq|$LIB->_acmp(\$y, \$y) = 0|);
312 $x = $LIB->_new("1234");
313 $y = $LIB->_new("987654321012345678");
314 is($LIB->_acmp($x, $y), -1, qq|$LIB->_acmp(\$x, \$y) = -1|);
315 is($LIB->_acmp($y, $x), 1, qq|$LIB->_acmp(\$y, \$x) = 1|);
316 is($LIB->_acmp($x, $x), 0, qq|$LIB->_acmp(\$x, \$x) = 0|);
317 is($LIB->_acmp($y, $y), 0, qq|$LIB->_acmp(\$y, \$y) = 0|);
321 $x = $LIB->_new("8");
322 $y = $LIB->_new("5033");
323 my ($xmod, $sign) = $LIB->_modinv($x, $y);
324 is($LIB->_str($xmod), "629", # -629 % 5033 == 4404
325 qq|$LIB->_str(\$xmod) = "629"|);
330 $x = $LIB->_new("3333");
331 $y = $LIB->_new("1111");
332 is($LIB->_str(scalar($LIB->_div($x, $y))), 3,
333 qq|$LIB->_str(scalar($LIB->_div(\$x, \$y))) = 3|);
335 $x = $LIB->_new("33333");
336 $y = $LIB->_new("1111");
337 ($x, $y) = $LIB->_div($x, $y);
338 is($LIB->_str($x), 30, qq|$LIB->_str(\$x) = 30|);
339 is($LIB->_str($y), 3, qq|$LIB->_str(\$y) = 3|);
341 $x = $LIB->_new("123");
342 $y = $LIB->_new("1111");
343 ($x, $y) = $LIB->_div($x, $y);
344 is($LIB->_str($x), 0, qq|$LIB->_str(\$x) = 0|);
345 is($LIB->_str($y), 123, qq|$LIB->_str(\$y) = 123|);
351 $x = $LIB->_new("$_");
353 is($LIB->_str($x), "$_", qq|$LIB->_str(\$x) = "$_"|);
355 $x = $LIB->_num($x);
362 $x = $LIB->_new("144");
363 is($LIB->_str($LIB->_sqrt($x)), "12",
364 qq|$LIB->_str($LIB->_sqrt(\$x)) = "12"|);
365 $x = $LIB->_new("144000000000000");
366 is($LIB->_str($LIB->_sqrt($x)), "12000000",
367 qq|$LIB->_str($LIB->_sqrt(\$x)) = "12000000"|);
371 $x = $LIB->_new("81");
372 my $n = $LIB->_new("3"); # 4*4*4 = 64, 5*5*5 = 125
373 is($LIB->_str($LIB->_root($x, $n)), "4",
374 qq|$LIB->_str($LIB->_root(\$x, \$n)) = "4"|); # 4.xx => 4.0
376 $x = $LIB->_new("81");
377 $n = $LIB->_new("4"); # 3*3*3*3 == 81
378 is($LIB->_str($LIB->_root($x, $n)), "3",
379 qq|$LIB->_str($LIB->_root(\$x, \$n)) = "3"|);
383 $x = $LIB->_new("0");
384 $n = $LIB->_new("3"); # 0 ** y => 0
385 is($LIB->_str($LIB->_pow($x, $n)), 0,
386 qq|$LIB->_str($LIB->_pow(\$x, \$n)) = 0|);
388 $x = $LIB->_new("3");
389 $n = $LIB->_new("0"); # x ** 0 => 1
390 is($LIB->_str($LIB->_pow($x, $n)), 1,
391 qq|$LIB->_str($LIB->_pow(\$x, \$n)) = 1|);
393 $x = $LIB->_new("1");
394 $n = $LIB->_new("3"); # 1 ** y => 1
395 is($LIB->_str($LIB->_pow($x, $n)), 1,
396 qq|$LIB->_str($LIB->_pow(\$x, \$n)) = 1|);
398 $x = $LIB->_new("5");
399 $n = $LIB->_new("1"); # x ** 1 => x
400 is($LIB->_str($LIB->_pow($x, $n)), 5,
401 qq|$LIB->_str($LIB->_pow(\$x, \$n)) = 5|);
403 $x = $LIB->_new("81");
404 $n = $LIB->_new("3"); # 81 ** 3 == 531441
405 is($LIB->_str($LIB->_pow($x, $n)), 81 ** 3,
406 qq|$LIB->_str($LIB->_pow(\$x, \$n)) = 81 ** 3|);
408 is($LIB->_str($LIB->_root($x, $n)), 81,
409 qq|$LIB->_str($LIB->_root(\$x, \$n)) = 81|);
411 $x = $LIB->_new("81");
412 is($LIB->_str($LIB->_pow($x, $n)), 81 ** 3,
413 qq|$LIB->_str($LIB->_pow(\$x, \$n)) = 81 ** 3|);
414 is($LIB->_str($LIB->_pow($x, $n)), "150094635296999121", # 531441 ** 3
415 qq|$LIB->_str($LIB->_pow(\$x, \$n)) = "150094635296999121"|);
417 is($LIB->_str($LIB->_root($x, $n)), "531441",
418 qq|$LIB->_str($LIB->_root(\$x, \$n)) = "531441"|);
419 is($LIB->_str($LIB->_root($x, $n)), "81",
420 qq|$LIB->_str($LIB->_root(\$x, \$n)) = "81"|);
422 $x = $LIB->_new("81");
423 $n = $LIB->_new("14");
424 is($LIB->_str($LIB->_pow($x, $n)), "523347633027360537213511521",
425 qq|$LIB->_str($LIB->_pow(\$x, \$n)) = "523347633027360537213511521"|);
426 is($LIB->_str($LIB->_root($x, $n)), "81",
427 qq|$LIB->_str($LIB->_root(\$x, \$n)) = "81"|);
429 $x = $LIB->_new("523347633027360537213511520");
430 is($LIB->_str($LIB->_root($x, $n)), "80",
431 qq|$LIB->_str($LIB->_root(\$x, \$n)) = "80"|);
433 $x = $LIB->_new("523347633027360537213511522");
434 is($LIB->_str($LIB->_root($x, $n)), "81",
435 qq|$LIB->_str($LIB->_root(\$x, \$n)) = "81"|);
443 $x = $LIB->_new($x);
444 $n = $LIB->_new("2");
447 is($LIB->_str($LIB->_pow($x, $n)), $rc,
448 qq|$LIB->_str($LIB->_pow(\$x, \$n)) = $rc|);
455 $x = $LIB->_new($x);
457 $n = $LIB->_new($n);
460 unless is($LIB->_str($LIB->_root($x, $n)), '1',
461 qq|$LIB->_str($LIB->_root(\$x, \$n)) = '1'|);
464 $x = $LIB->_new($x);
465 $n = $LIB->_new("2");
467 unless is($LIB->_str($LIB->_root($x, $n)), $res->[$i-2],
468 qq|$LIB->_str($LIB->_root(\$x, \$n)) = $res->[$i-2]|);
475 $x = $LIB->_new("0");
476 is($LIB->_str($LIB->_fac($x)), "1",
477 qq|$LIB->_str($LIB->_fac(\$x)) = "1"|);
479 $x = $LIB->_new("1");
480 is($LIB->_str($LIB->_fac($x)), "1",
481 qq|$LIB->_str($LIB->_fac(\$x)) = "1"|);
483 $x = $LIB->_new("2");
484 is($LIB->_str($LIB->_fac($x)), "2",
485 qq|$LIB->_str($LIB->_fac(\$x)) = "2"|);
487 $x = $LIB->_new("3");
488 is($LIB->_str($LIB->_fac($x)), "6",
489 qq|$LIB->_str($LIB->_fac(\$x)) = "6"|);
491 $x = $LIB->_new("4");
492 is($LIB->_str($LIB->_fac($x)), "24",
493 qq|$LIB->_str($LIB->_fac(\$x)) = "24"|);
495 $x = $LIB->_new("5");
496 is($LIB->_str($LIB->_fac($x)), "120",
497 qq|$LIB->_str($LIB->_fac(\$x)) = "120"|);
499 $x = $LIB->_new("10");
500 is($LIB->_str($LIB->_fac($x)), "3628800",
501 qq|$LIB->_str($LIB->_fac(\$x)) = "3628800"|);
503 $x = $LIB->_new("11");
504 is($LIB->_str($LIB->_fac($x)), "39916800",
505 qq|$LIB->_str($LIB->_fac(\$x)) = "39916800"|);
507 $x = $LIB->_new("12");
508 is($LIB->_str($LIB->_fac($x)), "479001600",
509 qq|$LIB->_str($LIB->_fac(\$x)) = "479001600"|);
511 $x = $LIB->_new("13");
512 is($LIB->_str($LIB->_fac($x)), "6227020800",
513 qq|$LIB->_str($LIB->_fac(\$x)) = "6227020800"|);
517 $x = $LIB->_new("3");
518 $LIB->_fac($x);
519 is($LIB->_str($x), "6",
520 qq|$LIB->_str(\$x) = "6"|);
522 $x = $LIB->_new("13");
523 $LIB->_fac($x);
524 is($LIB->_str($x), "6227020800",
525 qq|$LIB->_str(\$x) = "6227020800"|);
530 $x = $LIB->_new("$_");
531 $LIB->_inc($x);
533 is($LIB->_str($x), $expected, qq|$LIB->_str(\$x) = $expected|);
534 $LIB->_dec($x);
535 is($LIB->_str($x), $_, qq|$LIB->_str(\$x) = $_|);
539 $x = $LIB->_new("$_");
540 $LIB->_inc($x);
542 is($LIB->_str($x), $expected, qq|$LIB->_str(\$x) = $expected|);
543 $LIB->_dec($x);
544 is($LIB->_str($x), $_, qq|$LIB->_str(\$x) = $_|);
551 $x = $LIB->_new("$p");
552 $LIB->_inc($x);
553 is($LIB->_str($x), $q, qq|\$x = $LIB->_new("$p"); $LIB->_inc()|);
555 $x = $LIB->_new("$q");
556 $LIB->_dec($x);
557 is($LIB->_str($x), $p, qq|\$x = $LIB->_new("$q"); $LIB->_dec()|);
564 $x = $LIB->_new("$p");
565 $LIB->_inc($x);
566 is($LIB->_str($x), $q, qq|\$x = $LIB->_new("$p"); $LIB->_inc()|);
568 $x = $LIB->_new("$q");
569 $LIB->_dec($x);
570 is($LIB->_str($x), $p, qq|\$x = $LIB->_new("$q"); $LIB->_dec()|);
573 $x = $LIB->_new("1000");
574 $LIB->_inc($x);
575 is($LIB->_str($x), "1001", qq|$LIB->_str(\$x) = "1001"|);
576 $LIB->_dec($x);
577 is($LIB->_str($x), "1000", qq|$LIB->_str(\$x) = "1000"|);
579 my $BL = $LIB -> _base_len();
584 $x = $LIB->_new($x);
585 $LIB->_inc($x);
586 is($LIB->_str($x), $z, qq|$LIB->_str(\$x) = $z|);
590 $x = $LIB->_new($x);
591 $LIB->_dec($x);
592 is($LIB->_str($x), $z, qq|$LIB->_str(\$x) = $z|);
602 $x = $LIB->_new("1000");
603 $y = $LIB->_new("3");
604 is($LIB->_str(scalar($LIB->_mod($x, $y))), 1,
605 qq|$LIB->_str(scalar($LIB->_mod(\$x, \$y))) = 1|);
607 $x = $LIB->_new("1000");
608 $y = $LIB->_new("2");
609 is($LIB->_str(scalar($LIB->_mod($x, $y))), 0,
610 qq|$LIB->_str(scalar($LIB->_mod(\$x, \$y))) = 0|);
614 $x = $LIB->_new("5");
615 $y = $LIB->_new("2");
616 is($LIB->_str(scalar($LIB->_xor($x, $y))), 7,
617 qq|$LIB->_str(scalar($LIB->_xor(\$x, \$y))) = 7|);
619 $x = $LIB->_new("5");
620 $y = $LIB->_new("2");
621 is($LIB->_str(scalar($LIB->_or($x, $y))), 7,
622 qq|$LIB->_str(scalar($LIB->_or(\$x, \$y))) = 7|);
624 $x = $LIB->_new("5");
625 $y = $LIB->_new("3");
626 is($LIB->_str(scalar($LIB->_and($x, $y))), 1,
627 qq|$LIB->_str(scalar($LIB->_and(\$x, \$y))) = 1|);
631 is($LIB->_str($LIB->_from_hex("0xFf")), 255,
632 qq|$LIB->_str($LIB->_from_hex("0xFf")) = 255|);
633 is($LIB->_str($LIB->_from_bin("0b10101011")), 160+11,
634 qq|$LIB->_str($LIB->_from_bin("0b10101011")) = 160+11|);
635 is($LIB->_str($LIB->_from_oct("0100")), 8*8,
636 qq|$LIB->_str($LIB->_from_oct("0100")) = 8*8|);
637 is($LIB->_str($LIB->_from_oct("01000")), 8*8*8,
638 qq|$LIB->_str($LIB->_from_oct("01000")) = 8*8*8|);
639 is($LIB->_str($LIB->_from_oct("010001")), 8*8*8*8+1,
640 qq|$LIB->_str($LIB->_from_oct("010001")) = 8*8*8*8+1|);
641 is($LIB->_str($LIB->_from_oct("010007")), 8*8*8*8+7,
642 qq|$LIB->_str($LIB->_from_oct("010007")) = 8*8*8*8+7|);
646 is($LIB->_str($LIB->_from_hex($LIB->_as_hex($LIB->_new("128")))), 128,
647 qq|$LIB->_str($LIB->_from_hex($LIB->_as_hex(|
648 . qq|$LIB->_new("128")))) = 128|);
649 is($LIB->_str($LIB->_from_bin($LIB->_as_bin($LIB->_new("128")))), 128,
650 qq|$LIB->_str($LIB->_from_bin($LIB->_as_bin(|
651 . qq|$LIB->_new("128")))) = 128|);
652 is($LIB->_str($LIB->_from_oct($LIB->_as_oct($LIB->_new("128")))), 128,
653 qq|$LIB->_str($LIB->_from_oct($LIB->_as_oct(|
654 . qq|$LIB->_new("128")))) = 128|);
656 is($LIB->_str($LIB->_from_oct($LIB->_as_oct($LIB->_new("123456")))),
658 qq|$LIB->_str($LIB->_from_oct($LIB->_as_oct|
659 . qq|($LIB->_new("123456")))) = 123456|);
660 is($LIB->_str($LIB->_from_oct($LIB->_as_oct($LIB->_new("123456789")))),
662 qq|$LIB->_str($LIB->_from_oct($LIB->_as_oct(|
663 . qq|$LIB->_new("123456789")))) = "123456789"|);
664 is($LIB->_str($LIB->_from_oct($LIB->_as_oct($LIB->_new("1234567890123")))),
666 qq|$LIB->_str($LIB->_from_oct($LIB->_as_oct(|
667 . qq|$LIB->_new("1234567890123")))) = "1234567890123"|);
670 is($LIB->_str($LIB->_from_hex($LIB->_as_hex($LIB->_new($long)))), $long,
671 qq|$LIB->_str($LIB->_from_hex($LIB->_as_hex(|
672 . qq|$LIB->_new("$long")))) = "$long"|);
673 is($LIB->_str($LIB->_from_bin($LIB->_as_bin($LIB->_new($long)))), $long,
674 qq|$LIB->_str($LIB->_from_bin($LIB->_as_bin(|
675 . qq|$LIB->_new("$long")))) = "$long"|);
676 is($LIB->_str($LIB->_from_oct($LIB->_as_oct($LIB->_new($long)))), $long,
677 qq|$LIB->_str($LIB->_from_oct($LIB->_as_oct(|
678 . qq|$LIB->_new("$long")))) = "$long"|);
680 is($LIB->_str($LIB->_from_hex($LIB->_as_hex($LIB->_new("0")))), 0,
681 qq|$LIB->_str($LIB->_from_hex($LIB->_as_hex(|
682 . qq|$LIB->_new("0")))) = 0|);
683 is($LIB->_str($LIB->_from_bin($LIB->_as_bin($LIB->_new("0")))), 0,
684 qq|$LIB->_str($LIB->_from_bin($LIB->_as_bin(|
685 . qq|$LIB->_new("0")))) = 0|);
686 is($LIB->_str($LIB->_from_oct($LIB->_as_oct($LIB->_new("0")))), 0,
687 qq|$LIB->_str($LIB->_from_oct($LIB->_as_oct(|
688 . qq|$LIB->_new("0")))) = 0|);
690 is($LIB->_as_hex($LIB->_new("0")), "0x0",
691 qq|$LIB->_as_hex($LIB->_new("0")) = "0x0"|);
692 is($LIB->_as_bin($LIB->_new("0")), "0b0",
693 qq|$LIB->_as_bin($LIB->_new("0")) = "0b0"|);
694 is($LIB->_as_oct($LIB->_new("0")), "00",
695 qq|$LIB->_as_oct($LIB->_new("0")) = "00"|);
697 is($LIB->_as_hex($LIB->_new("12")), "0xc",
698 qq|$LIB->_as_hex($LIB->_new("12")) = "0xc"|);
699 is($LIB->_as_bin($LIB->_new("12")), "0b1100",
700 qq|$LIB->_as_bin($LIB->_new("12")) = "0b1100"|);
701 is($LIB->_as_oct($LIB->_new("64")), "0100",
702 qq|$LIB->_as_oct($LIB->_new("64")) = "0100"|);
706 is($LIB->_str($LIB->_1ex(0)), "1",
707 qq|$LIB->_str($LIB->_1ex(0)) = "1"|);
708 is($LIB->_str($LIB->_1ex(1)), "10",
709 qq|$LIB->_str($LIB->_1ex(1)) = "10"|);
710 is($LIB->_str($LIB->_1ex(2)), "100",
711 qq|$LIB->_str($LIB->_1ex(2)) = "100"|);
712 is($LIB->_str($LIB->_1ex(12)), "1000000000000",
713 qq|$LIB->_str($LIB->_1ex(12)) = "1000000000000"|);
714 is($LIB->_str($LIB->_1ex(16)), "10000000000000000",
715 qq|$LIB->_str($LIB->_1ex(16)) = "10000000000000000"|);
719 $x = $LIB->_new("123456789");
720 is($LIB->_check($x), 0,
721 qq|$LIB->_check(\$x) = 0|);
722 is($LIB->_check(123), "123 is not a reference",
723 qq|$LIB->_check(123) = "123 is not a reference"|);
732 $x = &{$LIB."::__strip_zeros"}([]);
737 $x = &{$LIB."::__strip_zeros"}([0]);
740 $x = &{$LIB."::__strip_zeros"}([1]);
745 $x = &{$LIB."::__strip_zeros"}([0, 1]);
749 $x = &{$LIB."::__strip_zeros"}([0, 1, 2]);
756 $x = &{$LIB."::__strip_zeros"}([0, 1, 2, 0]);
762 $x = &{$LIB."::__strip_zeros"}([0, 1, 2, 0, 0]);
768 $x = &{$LIB."::__strip_zeros"}([0, 1, 2, 0, 0, 0]);
775 $x = &{$LIB."::__strip_zeros"}([0, 0, 0, 0]);