| 193 | | pasm_output_is( <<'CODE', <<'OUTPUT', "sub bigint" ); |
| 194 | | new P0, ['BigInt'] |
| 195 | | set P0, 12345678 |
| 196 | | new P1, ['BigInt'] |
| 197 | | set P1, 5678 |
| 198 | | new P2, ['BigInt'] |
| 199 | | sub P2, P0, P1 |
| 200 | | set I0, P2 |
| 201 | | eq I0, 12340000, OK1 |
| 202 | | print "not " |
| 203 | | OK1: print "ok 1\n" |
| 204 | | set P0, "123456789012345678" |
| 205 | | sub P2, P0, P1 |
| 206 | | new P3, ['BigInt'] |
| 207 | | set P3, "123456789012340000" |
| 208 | | eq P2, P3, OK2 |
| 209 | | print "not " |
| 210 | | OK2: print "ok 2\n" |
| 211 | | set P1, "223456789012345678" |
| 212 | | sub P2, P0, P1 |
| 213 | | set P3, "-100000000000000000" |
| 214 | | eq P2, P3, OK3 |
| 215 | | print "not " |
| 216 | | OK3: print "ok 3\n" |
| 217 | | end |
| 218 | | CODE |
| 219 | | ok 1 |
| 220 | | ok 2 |
| 221 | | ok 3 |
| 222 | | OUTPUT |
| | 132 | $P0 = 2147483646 |
| | 133 | $N1 = $P0 |
| | 134 | .fp_eq($N1, 2.147483646e9, OK5) |
| | 135 | $I1 = 0 |
| | 136 | say 'set_int/get_num 2^31-1 wrong' |
| | 137 | OK5: |
| 246 | | pasm_output_is( <<'CODE', <<'OUTPUT', "sub other int" ); |
| 247 | | new P0, ['BigInt'] |
| 248 | | set P0, 12345678 |
| 249 | | new P1, ['Integer'] |
| 250 | | set P1, 5678 |
| 251 | | new P2, ['BigInt'] |
| 252 | | sub P2, P0, P1 |
| 253 | | set I0, P2 |
| 254 | | eq I0, 12340000, OK1 |
| 255 | | print "not " |
| 256 | | OK1: print "ok 1\n" |
| 257 | | set P0, "123456789012345678" |
| 258 | | sub P2, P0, P1 |
| 259 | | new P3, ['BigInt'] |
| 260 | | set P3, "123456789012340000" |
| 261 | | eq P2, P3, OK2 |
| 262 | | print "not " |
| 263 | | OK2: print "ok 2\n" |
| 264 | | set P0, 9876543 |
| 265 | | new P4, ['Integer'] |
| 266 | | set P4, 44 |
| 267 | | sub P2, P0, P4 |
| 268 | | set I0, P2 |
| 269 | | eq I0, 9876499, OK3 |
| 270 | | print "not " |
| 271 | | OK3: print "ok 3\n" |
| 272 | | set P0, "9876543219876543" |
| 273 | | sub P2, P0, P4 |
| 274 | | set P3, "9876543219876499" |
| 275 | | eq P3, P2, OK4 |
| 276 | | print "not " |
| 277 | | OK4: print "ok 4\n" |
| 278 | | end |
| 279 | | CODE |
| 280 | | ok 1 |
| 281 | | ok 2 |
| 282 | | ok 3 |
| 283 | | ok 4 |
| 284 | | OUTPUT |
| | 146 | $P0 = new ['BigInt'] |
| | 147 | $P0 = 1.23e12 |
| | 148 | $S0 = $P0 |
| | 149 | eq $S0, '1230000000000', OK7 |
| | 150 | $I1 = 0 |
| | 151 | say 'set_num/get_str 1230000000000' |
| | 152 | OK7: |
| 404 | | for my $op ( "/", "%" ) { |
| 405 | | for my $type ( "BigInt", "Integer" ) { |
| 406 | | pir_output_is( <<"CODE", <<OUTPUT, "bigint $op by zero $type" ); |
| 407 | | .sub _main :main |
| 408 | | \$P0 = new ['BigInt'] |
| 409 | | set \$P0, "1000000000000000000000" |
| 410 | | \$P1 = new ['BigInt'] |
| 411 | | ## divide by a zero $type |
| 412 | | \$P2 = new ['$type'] |
| 413 | | set \$P2, 0 |
| 414 | | push_eh OK |
| 415 | | \$P1 = \$P0 $op \$P2 |
| 416 | | print "fail\\n" |
| 417 | | pop_eh |
| 418 | | OK: |
| 419 | | get_results '0', \$P0 |
| 420 | | \$S0 = \$P0 |
| 421 | | print "ok\\n" |
| 422 | | print \$S0 |
| 423 | | print "\\n" |
| | 242 | $P0 = 12345678 |
| | 243 | $P2 = sub $P0, 5678 |
| | 244 | $I0 = $P2 |
| | 245 | eq $I0, 12340000, OK4 |
| | 246 | $I1 = 0 |
| | 247 | say 'sub 12345678-5678 wrong' |
| | 248 | OK4: |
| | 249 | |
| | 250 | $P0 = '123456789012345678' |
| | 251 | $P2 = sub $P0, 5678 |
| | 252 | $P3 = new ['BigInt'] |
| | 253 | $P3 = '123456789012340000' |
| | 254 | eq $P2, $P3, OK5 |
| | 255 | $I1 = 0 |
| | 256 | say 'sub 123456789012345678-5678 wrong' |
| | 257 | OK5: |
| | 258 | |
| | 259 | $P0 = new ['BigInt'] |
| | 260 | $P0 = 12345678 |
| | 261 | $P1 = new ['Integer'] |
| | 262 | $P1 = 5678 |
| | 263 | $P2 = new ['BigInt'] |
| | 264 | $P2 = sub $P0, $P1 |
| | 265 | $I0 = $P2 |
| | 266 | eq $I0, 12340000, OK6 |
| | 267 | $I1 = 0 |
| | 268 | say 'sub 12345678-5678 wrong' |
| | 269 | OK6: |
| | 270 | |
| | 271 | $P0 = '123456789012345678' |
| | 272 | $P2 = sub $P0, $P1 |
| | 273 | $P3 = new ['BigInt'] |
| | 274 | $P3 = '123456789012340000' |
| | 275 | eq $P2, $P3, OK7 |
| | 276 | $I1 = 0 |
| | 277 | say 'sub 123456789012345678-5678 wrong' |
| | 278 | OK7: |
| | 279 | |
| | 280 | $P0 = 9876543 |
| | 281 | $P4 = new ['Integer'] |
| | 282 | $P4 = 44 |
| | 283 | $P2 = sub $P0, $P4 |
| | 284 | $I0 = $P2 |
| | 285 | eq $I0, 9876499, OK8 |
| | 286 | $I1 = 0 |
| | 287 | say 'sub 9876543-44 wrong' |
| | 288 | OK8: |
| | 289 | |
| | 290 | $P0 = '9876543219876543' |
| | 291 | $P2 = sub $P0, $P4 |
| | 292 | $P3 = '9876543219876499' |
| | 293 | eq $P3, $P2, OK9 |
| | 294 | $I1 = 0 |
| | 295 | say 'sub 9876543219876543-44 wrong' |
| | 296 | OK9: |
| | 297 | ok($I1, 'sub(bigint,integer)') |
| 432 | | { |
| 433 | | my ( $a, $b, $c, $d, $e ); |
| 434 | | if ( $PConfig{intvalsize} == 8 ) { |
| 435 | | $a = '9223372036854775806'; # 2**63-2 |
| 436 | | $b = '1'; |
| 437 | | $c = '9223372036854775807'; # still Integer |
| 438 | | $d = '9223372036854775808'; # no more Integer |
| 439 | | $e = '9223372036854775809'; # still no more Integer |
| 440 | | } |
| 441 | | elsif ( $PConfig{intvalsize} == 4 ) { |
| 442 | | $a = '2147483646'; # 2**31-2 |
| 443 | | $b = '1'; |
| 444 | | $c = '2147483647'; # still Integer |
| 445 | | $d = '2147483648'; # no more PerlInt |
| 446 | | $e = '2147483649'; # still no more PerlInt |
| 447 | | } |
| 448 | | else { |
| 449 | | die "\$PConfig{intvalsize} == $PConfig{intvalsize}?\n"; |
| 450 | | } |
| | 300 | .sub multiplication |
| | 301 | $P0 = new ['BigInt'] |
| | 302 | $P0 = 999999 |
| | 303 | $P1 = new ['BigInt'] |
| | 304 | $P1 = 1000000 |
| | 305 | $P2 = new ['BigInt'] |
| | 306 | $P2 = mul $P0, $P1 |
| | 307 | $S0 = $P2 |
| | 308 | is($S0, '999999000000', 'mul(bigint,bigint)') |
| 532 | | .sub _main |
| 533 | | .local pmc pmc1 |
| 534 | | pmc1 = new ['BigInt'] |
| 535 | | .local int bool1 |
| 536 | | does bool1, pmc1, "scalar" |
| 537 | | print bool1 |
| 538 | | print "\n" |
| 539 | | does bool1, pmc1, "no_interface" |
| 540 | | print bool1 |
| 541 | | print "\n" |
| 542 | | end |
| | 348 | $P1 = -1 |
| | 349 | $P3 = '-100000000000000000000' |
| | 350 | $P2 = div $P0, $P1 |
| | 351 | eq $P2, $P3, OK4 |
| | 352 | $I1 = 0 |
| | 353 | say 'div 100000000000000000000/(-1) wrong' |
| | 354 | OK4: |
| | 355 | ok($I1, 'div(bigint,bigint)') |
| | 356 | $I1 = 1 |
| | 357 | |
| | 358 | $P0 = new ['BigInt'] |
| | 359 | $P0 = '100000000000000000000' |
| | 360 | $P1 = new ['BigInt'] |
| | 361 | $P1 = div $P0, 10 |
| | 362 | $P2 = new ['BigInt'] |
| | 363 | $P2 = '10000000000000000000' |
| | 364 | eq $P1, $P2, OK5 |
| | 365 | $I1 = 0 |
| | 366 | say 'div 100000000000000000000/10 wrong' |
| | 367 | OK5: |
| | 368 | |
| | 369 | $P0 = '100000000000000' |
| | 370 | $P1 = div $P0, 10000000 |
| | 371 | $P2 = 10000000 |
| | 372 | eq $P1, $P2, OK6 |
| | 373 | $I1 = 0 |
| | 374 | say 'div 100000000000000/10000000 wrong' |
| | 375 | OK6: |
| | 376 | ok($I1, 'div(bigint,nativeint)') |
| | 377 | $I1 = 1 |
| | 378 | |
| | 379 | $P0 = new ['BigInt'] |
| | 380 | $P0 = '100000000000000000000' |
| | 381 | $P1 = new ['BigInt'] |
| | 382 | $P3 = new ['Integer'] |
| | 383 | $P3 = 10 |
| | 384 | $P1 = div $P0, $P3 |
| | 385 | $P2 = new ['BigInt'] |
| | 386 | $P2 = '10000000000000000000' |
| | 387 | eq $P1, $P2, OK7 |
| | 388 | $I1 = 0 |
| | 389 | say 'div 100000000000000000000/10 wrong' |
| | 390 | OK7: |
| | 391 | |
| | 392 | $P0 = '100000000000000' |
| | 393 | $P4 = new ['Integer'] |
| | 394 | $P4 = 10000000 |
| | 395 | $P1 = div $P0, $P4 |
| | 396 | $P2 = 10000000 |
| | 397 | eq $P1, $P2, OK8 |
| | 398 | $I1 = 0 |
| | 399 | say 'div 100000000000000/10000000 wrong' |
| | 400 | OK8: |
| | 401 | ok($I1, 'div(bigint,integer)') |
| | 402 | |
| 549 | | pasm_output_is( <<"CODE", <<'OUTPUT', "Truth" ); |
| 550 | | new P0, ['BigInt'] |
| 551 | | set P0, "123456789123456789" |
| 552 | | if P0, OK1 |
| 553 | | print "not " |
| 554 | | OK1: print "ok 1\\n" |
| 555 | | set P0, 0 |
| 556 | | unless P0, OK2 |
| 557 | | print "not " |
| 558 | | OK2: print "ok 2\\n" |
| 559 | | end |
| 560 | | CODE |
| 561 | | ok 1 |
| 562 | | ok 2 |
| 563 | | OUTPUT |
| | 405 | .sub division_by_zero |
| | 406 | $I1 = 1 |
| | 407 | $P0 = new ['BigInt'] |
| | 408 | $P0 = '1000000000000000000000' |
| | 409 | $P1 = new ['BigInt'] |
| | 410 | ## divide by a zero BigInt |
| | 411 | $P2 = new ['BigInt'] |
| | 412 | $P2 = 0 |
| | 413 | push_eh E1 |
| | 414 | $P1 = div $P0, $P2 |
| | 415 | $I1 = 0 |
| | 416 | say 'Failed to throw exception' |
| | 417 | E1: |
| | 418 | pop_eh |
| | 419 | get_results '0', $P0 |
| | 420 | $S0 = $P0 |
| | 421 | eq $S0, 'Divide by zero', OK1 |
| | 422 | $I1 = 0 |
| | 423 | print $S0 |
| | 424 | say ' is wrong exception type' |
| | 425 | OK1: |
| | 426 | ok($I1, 'div(bigint,bigint 0) throws "Divide by zero" exception') |
| | 427 | $I1 = 1 |
| 565 | | pasm_output_is( <<"CODE", <<'OUTPUT', "neg" ); |
| 566 | | new P0, ['BigInt'] |
| 567 | | new P1, ['BigInt'] |
| 568 | | set P0, "123456789123456789" |
| 569 | | neg P0 |
| 570 | | set P1, "-123456789123456789" |
| 571 | | eq P0, P1, OK1 |
| 572 | | print "not " |
| 573 | | OK1: print "ok 1\\n" |
| 574 | | end |
| 575 | | CODE |
| 576 | | ok 1 |
| 577 | | OUTPUT |
| | 429 | $P0 = new ['BigInt'] |
| | 430 | $P0 = '1000000000000000000000' |
| | 431 | $P1 = new ['BigInt'] |
| | 432 | ## modulus by a zero BigInt |
| | 433 | $P2 = new ['BigInt'] |
| | 434 | $P2 = 0 |
| | 435 | push_eh E2 |
| | 436 | $P1 = mod $P0, $P2 |
| | 437 | $I1 = 0 |
| | 438 | say 'Failed to throw exception' |
| | 439 | E2: |
| | 440 | pop_eh |
| | 441 | get_results '0', $P0 |
| | 442 | $S0 = $P0 |
| | 443 | eq $S0, 'Divide by zero', OK2 |
| | 444 | $I1 = 0 |
| | 445 | print $S0 |
| | 446 | say ' is wrong exception type' |
| | 447 | OK2: |
| | 448 | ok($I1, 'mod(bigint,bigint 0) throws "Divide by zero" exception') |
| | 449 | $I1 = 1 |
| 579 | | pir_output_is( <<'CODE', <<'OUTPUT', "pi() generator" ); |
| 580 | | .sub PI |
| 581 | | .local pmc k, a, b, a1, b1 |
| 582 | | k = new ['Integer'] |
| 583 | | k = 2 |
| 584 | | a = new ['Integer'] |
| 585 | | a = 4 |
| 586 | | b = new ['Integer'] |
| 587 | | b = 1 |
| 588 | | a1 = new ['Integer'] |
| 589 | | a1 = 12 |
| 590 | | b1 = new ['Integer'] |
| 591 | | b1 = 4 |
| 592 | | forever: |
| 593 | | .local pmc p, q |
| 594 | | p = mul k, k |
| 595 | | q = mul k, 2 |
| 596 | | inc q |
| 597 | | inc k |
| 598 | | .local pmc ta, tb, ta1, tb1 |
| 599 | | ta = clone a1 |
| 600 | | tb = clone b1 |
| 601 | | $P0 = mul p, a |
| 602 | | $P1 = mul q, a1 |
| 603 | | ta1 = add $P0, $P1 |
| 604 | | $P2 = mul p, b |
| 605 | | $P3 = mul q, b1 |
| 606 | | tb1 = add $P2, $P3 |
| 607 | | a = ta |
| 608 | | b = tb |
| 609 | | a1 = ta1 |
| 610 | | b1 = tb1 |
| 611 | | .local pmc d, d1 |
| 612 | | d = fdiv a, b |
| 613 | | d1 = fdiv a1, b1 |
| 614 | | yield_loop: |
| 615 | | unless d == d1 goto end_yield |
| 616 | | .yield(d) |
| 617 | | $P4 = mod a, b |
| 618 | | a = mul $P4, 10 |
| 619 | | $P5 = mod a1, b1 |
| 620 | | a1 = mul $P5, 10 |
| 621 | | d = fdiv a, b |
| 622 | | d1 = fdiv a1, b1 |
| 623 | | goto yield_loop |
| 624 | | end_yield: |
| 625 | | goto forever |
| | 451 | $P0 = new ['BigInt'] |
| | 452 | $P0 = '1000000000000000000000' |
| | 453 | $P1 = new ['BigInt'] |
| | 454 | ## divide by a zero Integer |
| | 455 | $P2 = new ['Integer'] |
| | 456 | $P2 = 0 |
| | 457 | push_eh E3 |
| | 458 | $P1 = div $P0, $P2 |
| | 459 | $I1 = 0 |
| | 460 | say 'Failed to throw exception' |
| | 461 | E3: |
| | 462 | pop_eh |
| | 463 | get_results '0', $P0 |
| | 464 | $S0 = $P0 |
| | 465 | eq $S0, 'Divide by zero', OK3 |
| | 466 | $I1 = 0 |
| | 467 | print $S0 |
| | 468 | say ' is wrong exception type' |
| | 469 | OK3: |
| | 470 | ok($I1, 'div(bigint,integer 0) throws "Divide by zero" exception') |
| | 471 | $I1 = 1 |
| | 472 | |
| | 473 | $P0 = new ['BigInt'] |
| | 474 | $P0 = '1000000000000000000000' |
| | 475 | $P1 = new ['BigInt'] |
| | 476 | ## modulus by a zero Integer |
| | 477 | $P2 = new ['Integer'] |
| | 478 | $P2 = 0 |
| | 479 | push_eh E4 |
| | 480 | $P1 = mod $P0, $P2 |
| | 481 | $I1 = 0 |
| | 482 | say 'Failed to throw exception' |
| | 483 | E4: |
| | 484 | pop_eh |
| | 485 | get_results '0', $S0 |
| | 486 | eq $S0, 'Divide by zero', OK4 |
| | 487 | $I1 = 0 |
| | 488 | print $S0 |
| | 489 | say ' is wrong exception type' |
| | 490 | OK4: |
| | 491 | ok($I1, 'mod(bigint,integer 0) throws "Divide by zero" exception') |
| | 492 | |
| 644 | | =begin python |
| | 514 | .sub absolute_value |
| | 515 | $P0 = new ['BigInt'] |
| | 516 | $P0 = '-1230000000000000000000' |
| | 517 | $P1 = new ['Undef'] |
| | 518 | $P1 = abs $P0 |
| | 519 | $S0 = $P1 |
| | 520 | is($S0,'1230000000000000000000','abs negates negative number') |
| | 521 | $S0 = $P0 |
| | 522 | is($S0,'-1230000000000000000000','... and original unchanged with 2-arg form') |
| | 523 | $P1 = abs $P1 |
| | 524 | $S0 = $P1 |
| | 525 | is($S0,'1230000000000000000000','... does not change to positive number') |
| | 526 | $S0 = $P1 |
| | 527 | abs $P0 |
| | 528 | $S0 = $P0 |
| | 529 | is($S0,'1230000000000000000000','... and in-place works too') |
| | 530 | .end |
| 646 | | class PI(object): |
| 647 | | def __iter__(self): |
| 648 | | k, a, b, a1, b1 = 2, 4, 1, 12, 4 |
| 649 | | while 1: |
| 650 | | p, q, k = k*k, 2*k+1, k+1 |
| 651 | | a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 |
| 652 | | d, d1 = a//b, a1//b1 |
| 653 | | while d == d1: |
| 654 | | yield d |
| 655 | | a, a1 = 10*(a%b), 10*(a1%b1) |
| 656 | | d, d1 = a//b, a1//b1 |
| | 532 | .sub overflow_coercion |
| | 533 | # check libgmp included in Parrot build |
| | 534 | $P0 = getinterp |
| | 535 | $P4 = $P0[.IGLOBALS_CONFIG_HASH] |
| | 536 | $I0 = $P4['intvalsize'] |
| | 537 | eq $I0, 8, sz8 |
| | 538 | eq $I0, 4, sz4 |
| | 539 | print 'Cannot cope with sizeof(INTVAL) == ' |
| | 540 | say $I0 |
| | 541 | skip(43) |
| | 542 | exit 1 |
| 658 | | pi = iter(PI()) |
| 659 | | ds = "" |
| 660 | | for i in xrange(1, 1001): |
| 661 | | d = pi.next() |
| 662 | | ds += str(d) |
| 663 | | im = i % 50 |
| 664 | | if im == 0: |
| 665 | | print ds |
| 666 | | ds = "" |
| | 544 | sz8: |
| | 545 | $I3 = 0x100000000 # sqrt(2*(MinInt+1)) |
| | 546 | $I4 = 9223372036854775806 # MaxInt-1 == 2**63-2 |
| | 547 | $I5 = 9223372036854775807 # MaxInt |
| | 548 | $S5 = '9223372036854775807' # MaxInt |
| | 549 | $S6 = '9223372036854775808' # MaxInt+1 |
| | 550 | $S7 = '9223372036854775809' # MaxInt+2 |
| | 551 | $I8 = -9223372036854775807 # MinInt+1 == 1-2**63 |
| | 552 | $I9 = -9223372036854775808 # MinInt |
| | 553 | $S9 = '-9223372036854775808' # MinInt |
| | 554 | $S10 = '-9223372036854775809' # MinInt-1 |
| | 555 | $S11 = '-9223372036854775810' # MinInt-2 |
| | 556 | goto esz |
| 668 | | print ds |
| | 558 | sz4: |
| | 559 | $I3 = 0x10000 # sqrt(2*(MinInt+1)) |
| | 560 | $I4 = 2147483646 # MaxInt-1 == 2**31-2 |
| | 561 | $I5 = 2147483647 # MaxInt |
| | 562 | $S5 = '2147483647' # MaxInt |
| | 563 | $S6 = '2147483648' # MaxInt+1 |
| | 564 | $S7 = '2147483649' # MaxInt+2 |
| | 565 | $I8 = -2147483647 # MinInt+1 == 1-2**31 |
| | 566 | $I9 = -2147483648 # MinInt |
| | 567 | $S9 = '-2147483648' # MinInt |
| | 568 | $S10 = '-2147483649' # MinInt-1 |
| | 569 | $S11 = '-2147483650' # MinInt-2 |
| | 570 | goto esz |
| 674 | | CODE |
| | 622 | # Checking upper bound by increased steps |
| | 623 | $P0 = new ['Integer'] |
| | 624 | $P0 = $I4 # MaxInt-1 |
| | 625 | $P2 = new ['Integer'] |
| | 626 | $P2 = add $P0, $P1 |
| | 627 | $S0 = typeof $P2 |
| | 628 | eq $S0, 'Integer', k6 |
| | 629 | $I1 = 0 |
| | 630 | say "typeof != 'Integer'" |
| | 631 | k6: |
| | 632 | $S0 = $P2 |
| | 633 | eq $S0, $S5, k7 # MaxInt |
| | 634 | $I1 = 0 |
| | 635 | say 'value != MaxInt' |
| | 636 | k7: |
| | 637 | inc $P1 |
| | 638 | $P2 = new ['Integer'] |
| | 639 | $P2 = add $P0, $P1 |
| | 640 | $S0 = typeof $P2 |
| | 641 | eq $S0, 'BigInt', k8 |
| | 642 | $I1 = 0 |
| | 643 | say "typeof != 'BigInt'" |
| | 644 | k8: |
| | 645 | $S0 = $P2 |
| | 646 | eq $S0, $S6, k9 # MaxInt+1 |
| | 647 | $I1 = 0 |
| | 648 | say 'value != MaxInt+1' |
| | 649 | k9: |
| | 650 | add $P1, 1 |
| | 651 | $P2 = new ['Integer'] |
| | 652 | $P2 = add $P0, $P1 |
| | 653 | $S0 = typeof $P2 |
| | 654 | eq $S0, 'BigInt', k10 |
| | 655 | $I1 = 0 |
| | 656 | say "typeof != 'BigInt'" |
| | 657 | k10: |
| | 658 | $S0 = $P2 |
| | 659 | eq $S0, $S7, k11 # MaxInt+2 |
| | 660 | $I1 = 0 |
| | 661 | say 'value != MaxInt+2' |
| | 662 | k11: |
| | 663 | ok($I1, 'integer addition converts MaxInt+1 to BigInt') |
| | 664 | |
| | 665 | # Checking lower bound |
| | 666 | $I1 = 6 |
| | 667 | $P0 = new ['Integer'] |
| | 668 | $P0 = $I8 |
| | 669 | $P1 = -1 |
| | 670 | $P2 = new ['Integer'] |
| | 671 | $P2 = add $P0, $P1 |
| | 672 | $S0 = typeof $P2 |
| | 673 | ne $S0, 'Integer', k12 |
| | 674 | dec $I1 |
| | 675 | k12: |
| | 676 | $S0 = $P2 |
| | 677 | ne $S0, $S9, k13 |
| | 678 | dec $I1 |
| | 679 | k13: |
| | 680 | dec $P1 |
| | 681 | $P2 = new ['Integer'] |
| | 682 | $P2 = add $P0, $P1 |
| | 683 | $S0 = typeof $P2 |
| | 684 | ne $S0, 'BigInt', k14 |
| | 685 | dec $I1 |
| | 686 | k14: |
| | 687 | $S0 = $P2 |
| | 688 | ne $S0, $S10, k15 |
| | 689 | dec $I1 |
| | 690 | k15: |
| | 691 | sub $P1, 1 |
| | 692 | $P2 = new ['Integer'] |
| | 693 | $P2 = add $P0, $P1 |
| | 694 | $S0 = typeof $P2 |
| | 695 | ne $S0, 'BigInt', k16 |
| | 696 | dec $I1 |
| | 697 | k16: |
| | 698 | $S0 = $P2 |
| | 699 | ne $S0, $S11, k17 |
| | 700 | dec $I1 |
| | 701 | k17: |
| | 702 | is($I1, 0, 'integer addition converts MinInt+(-1) to BigInt') |
| | 703 | |
| | 704 | $I1 = 6 |
| | 705 | $P0 = new ['Integer'] |
| | 706 | $P0 = $I4 |
| | 707 | $P1 = -1 |
| | 708 | $P2 = new ['Integer'] |
| | 709 | $P2 = sub $P0, $P1 |
| | 710 | $S0 = typeof $P2 |
| | 711 | ne $S0, 'Integer', k18 |
| | 712 | dec $I1 |
| | 713 | k18: |
| | 714 | $S0 = $P2 |
| | 715 | ne $S0, $S5, k19 |
| | 716 | dec $I1 |
| | 717 | k19: |
| | 718 | dec $P1 |
| | 719 | $P2 = new ['Integer'] |
| | 720 | $P2 = sub $P0, $P1 |
| | 721 | $S0 = typeof $P2 |
| | 722 | ne $S0, 'BigInt', k20 |
| | 723 | dec $I1 |
| | 724 | k20: |
| | 725 | $S0 = $P2 |
| | 726 | ne $S0, $S6, k21 |
| | 727 | dec $I1 |
| | 728 | k21: |
| | 729 | sub $P1, 1 |
| | 730 | $P2 = new ['Integer'] |
| | 731 | $P2 = sub $P0, $P1 |
| | 732 | $S0 = typeof $P2 |
| | 733 | ne $S0, 'BigInt', k22 |
| | 734 | dec $I1 |
| | 735 | k22: |
| | 736 | $S0 = $P2 |
| | 737 | ne $S0, $S7, k23 |
| | 738 | dec $I1 |
| | 739 | k23: |
| | 740 | is($I1, 0, 'integer subtraction converts MaxInt-(-1) to BigInt') |
| | 741 | |
| | 742 | $I1 = 0 |
| | 743 | $P0 = new ['Integer'] |
| | 744 | $P0 = $I8 # MinInt |
| | 745 | dec $P0 |
| | 746 | neg $P0 |
| | 747 | $S0 = typeof $P0 |
| | 748 | ne $S0, 'BigInt', k24 |
| | 749 | inc $I1 |
| | 750 | k24: |
| | 751 | $S0 = $P0 |
| | 752 | ne $S0, $S6, k25 |
| | 753 | inc $I1 |
| | 754 | k25: |
| | 755 | todo($I1, 'integer negation of MinInt converts MaxInt+1 to BigInt') |
| | 756 | |
| | 757 | $I1 = 0 |
| | 758 | $P0 = new ['Integer'] |
| | 759 | $P0 = $I8 # MinInt |
| | 760 | dec $P0 |
| | 761 | abs $P0 |
| | 762 | $S0 = typeof $P0 |
| | 763 | ne $S0, 'BigInt', k26 |
| | 764 | inc $I1 |
| | 765 | k26: |
| | 766 | $S0 = $P0 |
| | 767 | ne $S0, $S6, k27 |
| | 768 | inc $I1 |
| | 769 | k27: |
| | 770 | todo($I1, 'integer absolute-value of MinInt converts MaxInt+1 to BigInt') |
| | 771 | |
| | 772 | $P0 = new ['Integer'] |
| | 773 | $P0 = $I3 |
| | 774 | $P1 = new ['Integer'] |
| | 775 | $P1 = $I3 |
| | 776 | |
| | 777 | ex: |
| | 778 | .end |
| | 779 | |
| | 780 | .sub interface |
| | 781 | $P0 = new ['BigInt'] |
| | 782 | $I0 = does $P0, 'scalar' |
| | 783 | is($I0,1,'Interface does scalar') |
| | 784 | $I0 = does $P0, 'no_interface' |
| | 785 | is($I0,0,'... and does not do bogus') |
| | 786 | .end |
| | 787 | |
| | 788 | .sub boolean |
| | 789 | $P0 = new ['BigInt'] |
| | 790 | |
| | 791 | $P0 = '123456789123456789' |
| | 792 | $I0 = 1 |
| | 793 | if $P0, OK1 |
| | 794 | $I0 = 0 |
| | 795 | OK1: |
| | 796 | |
| | 797 | $P0 = 0 |
| | 798 | unless $P0, OK2 |
| | 799 | $I0 = 0 |
| | 800 | OK2: |
| | 801 | |
| | 802 | ok($I0, 'truth and falsehood') |
| | 803 | .end |
| | 804 | |
| | 805 | # How this next test was originally written in Python: |
| | 806 | # |
| | 807 | # class PI(object): |
| | 808 | # def __iter__(self): |
| | 809 | # k, a, b, a1, b1 = 2, 4, 1, 12, 4 |
| | 810 | # while 1: |
| | 811 | # p, q, k = k*k, 2*k+1, k+1 |
| | 812 | # a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 |
| | 813 | # d, d1 = a//b, a1//b1 |
| | 814 | # while d == d1: |
| | 815 | # yield d |
| | 816 | # a, a1 = 10*(a%b), 10*(a1%b1) |
| | 817 | # d, d1 = a//b, a1//b1 |
| | 818 | # |
| | 819 | # pi = iter(PI()) |
| | 820 | # ds = "" |
| | 821 | # for i in xrange(1, 1001): |
| | 822 | # d = pi.next() |
| | 823 | # ds += str(d) |
| | 824 | # im = i % 50 |
| | 825 | # if im == 0: |
| | 826 | # print ds |
| | 827 | # ds = "" |
| | 828 | # |
| | 829 | # print ds |
| | 830 | # |
| | 831 | |
| | 832 | .sub pi_generator |
| | 833 | # k = $P6 |
| | 834 | $P6 = new ['Integer'] |
| | 835 | $P6 = 2 |
| | 836 | # a = $P7 |
| | 837 | $P7 = new ['Integer'] |
| | 838 | $P7 = 4 |
| | 839 | # b = $P8 |
| | 840 | $P8 = new ['Integer'] |
| | 841 | $P8 = 1 |
| | 842 | # a1 = $P9 |
| | 843 | $P9 = new ['Integer'] |
| | 844 | $P9 = 12 |
| | 845 | # b1 = $P10 |
| | 846 | $P10 = new ['Integer'] |
| | 847 | $P10 = 4 |
| | 848 | restart: |
| | 849 | # p = $P11 |
| | 850 | $P11 = mul $P6, $P6 |
| | 851 | # q = $P12 |
| | 852 | $P12 = mul $P6, 2 |
| | 853 | inc $P12 |
| | 854 | inc $P6 |
| | 855 | # ta = $P13 |
| | 856 | $P13 = clone $P9 |
| | 857 | # tb = $P14 |
| | 858 | $P14 = clone $P10 |
| | 859 | $P0 = mul $P11, $P7 |
| | 860 | $P1 = mul $P12, $P9 |
| | 861 | # ta1 = $P15 |
| | 862 | $P15 = add $P0, $P1 |
| | 863 | $P2 = mul $P11, $P8 |
| | 864 | $P3 = mul $P12, $P10 |
| | 865 | # tb1 = $P16 |
| | 866 | $P16 = add $P2, $P3 |
| | 867 | $P7 = $P13 |
| | 868 | $P8 = $P14 |
| | 869 | $P9 = $P15 |
| | 870 | $P10 = $P16 |
| | 871 | # d = $P17 |
| | 872 | $P17 = fdiv $P7, $P8 |
| | 873 | # d1 = $P18 |
| | 874 | $P18 = fdiv $P9, $P10 |
| | 875 | next: |
| | 876 | ne $P17, $P18, restart |
| | 877 | .yield($P17) |
| | 878 | $P4 = mod $P7, $P8 |
| | 879 | $P7 = mul $P4, 10 |
| | 880 | $P5 = mod $P9, $P10 |
| | 881 | $P9 = mul $P5, 10 |
| | 882 | $P17 = fdiv $P7, $P8 |
| | 883 | $P18 = fdiv $P9, $P10 |
| | 884 | goto next |
| | 885 | .end |
| | 886 | |
| | 887 | .sub pi |
| | 888 | $S0 = <<'EoN' |
| 769 | | pir_output_is( <<'CODE', <<'OUT', "shl_int with a negative shift" ); |
| 770 | | ## cf the shr_int case. |
| 771 | | .sub main :main |
| 772 | | $P0 = new ['BigInt'] |
| 773 | | set $P0, 4 |
| 774 | | $P1 = new ['Integer'] |
| 775 | | set $P1, -1 |
| 776 | | $P2 = new ['BigInt'] |
| 777 | | shl $P2, $P0, $P1 |
| 778 | | say $P2 |
| 779 | | set $P0, "200000000000" |
| 780 | | set $P1, -1 |
| 781 | | shl $P2, $P0, $P1 |
| 782 | | say $P2 |
| 783 | | set $P0, "102400000000000" |
| 784 | | set $P1, -10 |
| 785 | | shl $P2, $P0, $P1 |
| 786 | | say $P2 |
| 787 | | .end |
| 788 | | CODE |
| 789 | | 2 |
| 790 | | 100000000000 |
| 791 | | 100000000000 |
| 792 | | OUT |
| | 965 | # shl with a negative shift |
| | 966 | $P0 = 8 |
| | 967 | $P1 = -2 |
| | 968 | $P2 = new ['Integer'] |
| | 969 | $P2 = shl $P0, $P1 |
| | 970 | $S0 = $P2 |
| | 971 | is($S0, '2', 'shl(bigint, -bigint)') |
| | 972 | $P0 = '102400000000000' |
| | 973 | $P1 = -10 |
| | 974 | $P2 = new ['Integer'] |
| | 975 | $P2 = shl $P0, $P1 |
| | 976 | $S0 = $P2 |
| | 977 | eq $S0, '100000000000', OK3 |
| | 978 | $I1 = 0 |
| | 979 | say 'shl(bigint 102400000000000,bigint -10) did not return 100000000000' |
| | 980 | OK3: |
| 794 | | pir_output_like( <<'CODE', <<'OUT', "shl_int and i_shl_int promote Integer to Bigint" ); |
| 795 | | ## The result on the second line is a BigInt on 32-bit systems and still an |
| 796 | | ## Integer on 64-bit systems. |
| 797 | | .sub main :main |
| 798 | | $P0 = new ['Integer'] |
| 799 | | set $P0, 1000001 |
| 800 | | $P1 = new ['Integer'] |
| 801 | | set $P1, 10 |
| 802 | | $P2 = new ['Integer'] |
| 803 | | ## shift by 10 bits . . . |
| 804 | | shl $P2, $P0, $P1 |
| 805 | | $S2 = typeof $P2 |
| 806 | | print $S2 |
| 807 | | print ' ' |
| 808 | | say $P2 |
| 809 | | ## then by 20 bits . . . |
| 810 | | $P1 = 20 |
| 811 | | $P3 = new ['Integer'] |
| 812 | | $P3 = 1000001 |
| 813 | | shl $P3, $P0, $P1 |
| 814 | | $S2 = typeof $P3 |
| 815 | | print $S2 |
| 816 | | print ' ' |
| 817 | | say $P3 |
| 818 | | ## then by another 40 bits (total 60) in place. |
| 819 | | $P1 = 40 |
| 820 | | shl $P3, $P3, $P1 |
| 821 | | $S2 = typeof $P3 |
| 822 | | print $S2 |
| 823 | | print ' ' |
| 824 | | say $P3 |
| 825 | | .end |
| 826 | | CODE |
| 827 | | /Integer 1024001024 |
| 828 | | (Integer|BigInt) 1048577048576 |
| 829 | | BigInt 1152922657528351582846976 |
| 830 | | / |
| 831 | | OUT |
| | 982 | ok($I1, 'shl(bigint, +bigint)') |
| | 983 | $I1 = 1 |
| 833 | | pir_error_output_like( <<'CODE', <<'OUT', "shl_int throws an error when promotion is disabled" ); |
| 834 | | .include "errors.pasm" |
| 835 | | .sub main :main |
| 836 | | errorson .PARROT_ERRORS_OVERFLOW_FLAG |
| 837 | | $P0 = new ['Integer'] |
| 838 | | set $P0, 1000001 |
| 839 | | $P1 = new ['Integer'] |
| 840 | | set $P1, 10 |
| 841 | | $P2 = new ['Integer'] |
| 842 | | ## shift by 10 bits . . . |
| 843 | | shl $P2, $P0, $P1 |
| 844 | | $S2 = typeof $P2 |
| 845 | | print $S2 |
| 846 | | print ' ' |
| 847 | | say $P2 |
| 848 | | ## then by 60 bits. |
| 849 | | $P1 = 60 |
| 850 | | $P0 = 1000001 |
| 851 | | shl $P3, $P0, $P1 |
| 852 | | $S2 = typeof $P3 |
| 853 | | print $S2 |
| 854 | | print ' ' |
| 855 | | say $P3 |
| 856 | | .end |
| 857 | | CODE |
| 858 | | /Integer 1024001024 |
| 859 | | Integer overflow |
| 860 | | current instr/ |
| 861 | | OUT |
| | 985 | # shl_int with a positive shift |
| | 986 | $P0 = 2 |
| | 987 | $P1 = 1 |
| | 988 | $P2 = new ['Integer'] |
| | 989 | $P2 = shl $P0, $P1 |
| | 990 | $S0 = $P2 |
| | 991 | eq $S0, '4', OK4 |
| | 992 | $I1 = 0 |
| | 993 | say 'shl(bigint 2,integer 1) did not return 4' |
| | 994 | OK4: |
| | 995 | $P0 = '100000000000' |
| | 996 | $P1 = 1 |
| | 997 | $P2 = new ['Integer'] |
| | 998 | $P2 = shl $P0, $P1 |
| | 999 | $S0 = $P2 |
| | 1000 | eq $S0, '200000000000', OK5 |
| | 1001 | $I1 = 0 |
| | 1002 | say 'shl(bigint 100000000000,integer 1) did not return 200000000000' |
| | 1003 | OK5: |
| | 1004 | $P0 = '100000000000' |
| | 1005 | $P1 = 10 |
| | 1006 | $P2 = new ['Integer'] |
| | 1007 | $P2 = shl $P0, $P1 |
| | 1008 | $S0 = $P2 |
| | 1009 | eq $S0, '102400000000000', OK6 |
| | 1010 | $I1 = 0 |
| | 1011 | say 'shl(bigint 100000000000,integer 10) did not return 102400000000000' |
| | 1012 | OK6: |
| 863 | | pir_output_is( <<'CODE', <<'OUT', "shl_int by 64 bits also promotes to Bigint" ); |
| | 1014 | # shl_int with a negative shift |
| | 1015 | |
| | 1016 | $P0 = 4 |
| | 1017 | $P1 = -1 |
| | 1018 | $P2 = new ['Integer'] |
| | 1019 | $P2 = shl $P0, $P1 |
| | 1020 | $S0 = $P2 |
| | 1021 | eq $S0, '2', OK7 |
| | 1022 | $I1 = 0 |
| | 1023 | say 'shl(bigint 4,integer -1) did not return 2' |
| | 1024 | OK7: |
| | 1025 | $P0 = '200000000000' |
| | 1026 | $P1 = -1 |
| | 1027 | $P2 = new ['Integer'] |
| | 1028 | $P2 = shl $P0, $P1 |
| | 1029 | $S0 = $P2 |
| | 1030 | eq $S0, '100000000000', OK8 |
| | 1031 | $I1 = 0 |
| | 1032 | say 'shl(bigint 200000000000,integer -1) did not return 100000000000' |
| | 1033 | OK8: |
| | 1034 | $P0 = '102400000000000' |
| | 1035 | $P1 = -10 |
| | 1036 | $P2 = new ['Integer'] |
| | 1037 | $P2 = shl $P0, $P1 |
| | 1038 | $S0 = $P2 |
| | 1039 | eq $S0, '100000000000', OK9 |
| | 1040 | $I1 = 0 |
| | 1041 | say 'shl(bigint 102400000000000,integer -10) did not return 100000000000' |
| | 1042 | OK9: |
| | 1043 | ok($I1, 'shl(bigint,integer)') |
| | 1044 | $I1 = 1 |
| | 1045 | |
| | 1046 | # shl_int throws an error when promotion is disabled |
| | 1047 | |
| | 1048 | errorson .PARROT_ERRORS_OVERFLOW_FLAG |
| | 1049 | $P0 = new ['Integer'] |
| | 1050 | $P0 = 1000001 |
| | 1051 | $P1 = new ['Integer'] |
| | 1052 | $P1 = 10 |
| | 1053 | |
| | 1054 | ## shift by 10 bits . . . |
| | 1055 | $P2 = new ['Integer'] |
| | 1056 | $P2 = shl $P0, $P1 |
| | 1057 | $S1 = $P2 |
| | 1058 | $S2 = typeof $P2 |
| | 1059 | eq $S2, 'Integer', OK11 |
| | 1060 | $I1 = 0 |
| | 1061 | print 'shl(integer 1000001,integer 10) did not return an Integer PMC; got a ' |
| | 1062 | print $S2 |
| | 1063 | say ' instead.' |
| | 1064 | |
| | 1065 | OK11: |
| | 1066 | eq $S1,'1024001024', OK12 |
| | 1067 | $I1 = 0 |
| | 1068 | print 'shl(integer 1000001,integer 10) did not return 1024001024; got ' |
| | 1069 | print $S1 |
| | 1070 | say ' instead.' |
| | 1071 | OK12: |
| | 1072 | |
| | 1073 | ## then by 60 bits. |
| | 1074 | $P0 = 1000001 |
| | 1075 | $P1 = 60 |
| | 1076 | push_eh E1 |
| | 1077 | $I1 = 1 |
| | 1078 | $P2 = new ['Integer'] |
| | 1079 | $P2 = shl $P0, $P1 |
| | 1080 | $I1 = 0 |
| | 1081 | $S1 = $P2 |
| | 1082 | $S2 = typeof $P2 |
| | 1083 | print 'Failed to throw exception; return type ' |
| | 1084 | print $S2 |
| | 1085 | print ', return value ' |
| | 1086 | say $P1 |
| | 1087 | E1: |
| | 1088 | pop_eh |
| | 1089 | get_results '0', $P2 |
| | 1090 | $S0 = $P2 |
| | 1091 | eq $S0, 'Integer overflow', OK13 |
| | 1092 | $I1 = 0 |
| | 1093 | say 'shl(integer 1000001, integer 60) throws exception, but wrong type' |
| | 1094 | OK13: |
| | 1095 | ok($I1, 'shl(integer 1000001, integer 60) throws "Integer overflow" exception') |
| | 1096 | $I1 = 1 |
| | 1097 | |
| | 1098 | # shl_int and i_shl_int promote Integer to Bigint |
| | 1099 | |
| | 1100 | errorsoff .PARROT_ERRORS_OVERFLOW_FLAG |
| | 1101 | ## shift left by 20 bits ... |
| | 1102 | $P0 = new ['Integer'] |
| | 1103 | $P0 = 1000001 |
| | 1104 | $P1 = new ['Integer'] |
| | 1105 | $P1 = 20 |
| | 1106 | $P2 = new ['Integer'] |
| | 1107 | $P2 = shl $P0, $P1 |
| | 1108 | ## ... then by another 40 bits (total 60) in place. |
| | 1109 | $P1 = 40 |
| | 1110 | $P2 = shl $P2, $P1 |
| | 1111 | $S1 = $P2 |
| | 1112 | $S2 = typeof $P2 |
| | 1113 | eq $S2, 'BigInt', OK14 |
| | 1114 | $S1 = '' |
| | 1115 | OK14: |
| | 1116 | is($S1, '1152922657528351582846976', 'shl(shl(integer 1000001, 20), 40) => bigint 1152922657528351582846976') |
| | 1117 | |
| | 1118 | # shl_int by 64 bits also promotes to Bigint |
| 931 | | pir_output_is( <<'CODE', <<'OUT', "shr_bigint with a negative shift" ); |
| | 1150 | ## then by another 50 bits (total 60) in place. |
| | 1151 | $P1 = -50 |
| | 1152 | $P2 = shr $P1 |
| | 1153 | $S1 = $P2 |
| | 1154 | $S2 = typeof $P2 |
| | 1155 | eq $S2, 'BigInt', OK2 |
| | 1156 | $S1 = '' |
| | 1157 | OK2: |
| | 1158 | is($S1, '1152922657528351582846976', 'shr(shr(integer 1000001, integer -10), -50) => bigint 1152922657528351582846976') |
| | 1159 | |
| | 1160 | # shr_bigint |
| | 1161 | $P0 = new ['BigInt'] |
| | 1162 | $P0 = 8 |
| | 1163 | $P1 = new ['BigInt'] |
| | 1164 | $P1 = 2 |
| | 1165 | $P2 = new ['BigInt'] |
| | 1166 | $P2 = shr $P0, $P1 |
| | 1167 | $S0 = $P2 |
| | 1168 | eq $S0, '2', OK3 |
| | 1169 | $I1 = 0 |
| | 1170 | say 'shr(bigint 8, bigint 2) did not return 2' |
| | 1171 | OK3: |
| | 1172 | |
| | 1173 | $P0 = '102400000000000' |
| | 1174 | $P1 = 10 |
| | 1175 | $P2 = shr $P0, $P1 |
| | 1176 | $S0 = $P2 |
| | 1177 | eq $S0, '100000000000', OK4 |
| | 1178 | $I1 = 0 |
| | 1179 | say 'shr(bigint 102400000000000, bigint 10) did not return 100000000000' |
| | 1180 | OK4: |
| | 1181 | ok($I1, 'shr(bigint, +bigint)') |
| | 1182 | $I1 = 1 |
| | 1183 | |
| | 1184 | # shr_bigint with a negative shift |
| 980 | | pir_output_is( <<'CODE', <<'OUT', "shr_int with a negative shift" ); |
| | 1199 | $P0 = '100000000000' |
| | 1200 | $P1 = -10 |
| | 1201 | $P2 = shr $P0, $P1 |
| | 1202 | $S0 = $P2 |
| | 1203 | eq $S0, '102400000000000', OK6 |
| | 1204 | $I1 = 0 |
| | 1205 | say 'shr(bigint 100000000000, bigint -10) did not return 102400000000000' |
| | 1206 | OK6: |
| | 1207 | ok($I1, 'shr(bigint, -bigint)') |
| | 1208 | $I1 = 1 |
| | 1209 | |
| | 1210 | # shr_int |
| | 1211 | $P0 = new ['BigInt'] |
| | 1212 | $P0 = 4 |
| | 1213 | $P1 = new ['Integer'] |
| | 1214 | $P1 = 1 |
| | 1215 | $P2 = new ['BigInt'] |
| | 1216 | $P2 = shr $P0, $P1 |
| | 1217 | $S0 = $P2 |
| | 1218 | eq $S0, '2', OK7 |
| | 1219 | $I1 = 0 |
| | 1220 | say 'shr(bigint 4, integer 1) did not return 2' |
| | 1221 | OK7: |
| | 1222 | |
| | 1223 | $P0 = '200000000000' |
| | 1224 | $P1 = 1 |
| | 1225 | $P2 = shr $P0, $P1 |
| | 1226 | $S0 = $P2 |
| | 1227 | eq $S0, '100000000000', OK8 |
| | 1228 | $I1 = 0 |
| | 1229 | say 'shr(bigint 200000000000, integer 1) did not return 100000000000' |
| | 1230 | OK8: |
| | 1231 | |
| | 1232 | $P0 = '102400000000000' |
| | 1233 | $P1 = 10 |
| | 1234 | $P2 = shr $P0, $P1 |
| | 1235 | $S0 = $P2 |
| | 1236 | eq $S0, '100000000000', OK9 |
| | 1237 | $I1 = 0 |
| | 1238 | say 'shr(bigint 102400000000000, integer 10) did not return 100000000000' |
| | 1239 | OK9: |
| | 1240 | |
| | 1241 | ok($I1,'shr(bigint, +integer)') |
| | 1242 | $I1 = 1 |
| | 1243 | |
| | 1244 | # shr_int with a negative shift |