Skip to content

Instantly share code, notes, and snippets.

@masak

masak/ints.p6 Secret

Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masak/e54c64fc2d51cdd1a0b7 to your computer and use it in GitHub Desktop.
Save masak/e54c64fc2d51cdd1a0b7 to your computer and use it in GitHub Desktop.
Doing with ints what I used to do with Strs
my int $s = 0b111111111;
say $s.fmt("%024b");
repeat until $s == 0b111111111000000000000000 {
my int $t = $s;
my int $u = 0;
for ^23 -> int $i {
if $t % 0x4 == 0x1 {
$s = (($t +& 0xFFFFFC +| 0x2) +< $i) +| $u;
last;
}
elsif $t +& 1 {
$u = ($u +< 1) +| 1;
}
$t +>= 1;
}
say $s.fmt("%024b");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment