Skip to content

Instantly share code, notes, and snippets.

@moritz
Created November 13, 2011 18:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save moritz/1362443 to your computer and use it in GitHub Desktop.
Please run on latest nqp/bigint on 32bit systems
use nqpmo;
my $knowhow := pir::get_knowhow__P();
my $bi_type := $knowhow.new_type(:name('TestBigInt'), :repr('P6bigint'));
$bi_type.HOW.compose($bi_type);
sub str($x) { pir::nqp_bigint_to_str__SP($x) };
sub iseq($x, $y) { nqp::iseq_I($x, nqp::box_i($y, $bi_type)) }
sub box($x) { nqp::box_i($x, $bi_type) }
my $i := 30;
while $i < 64 {
say($i);
my $x := nqp::pow_I(box(2), box($i), $bi_type);
nqp::print(' ');
say(nqp::tostr_I($x));
nqp::print(' ');
nqp::say(nqp::unbox_i($x));
nqp::print(' ');
nqp::say(nqp::isbig_I($x));
$i := $i + 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment