Skip to content

Instantly share code, notes, and snippets.

@lucs

lucs/foo.p6 Secret

Last active May 21, 2019 20:45
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 lucs/9bf69520a94f8472fdaed4cdcb451973 to your computer and use it in GitHub Desktop.
Save lucs/9bf69520a94f8472fdaed4cdcb451973 to your computer and use it in GitHub Desktop.
sub MAIN (*@sz) {
for @sz -> $sz {
my int @a = ^$sz;
my $s = @a.sum;
my $w = @a.sum(:wrap);
printf "%d : %10d %s %d\n",
$sz,
$s,
($s == $w ?? '==' !! '!='),
$w,
;
}
}
# --------------------------------------------------------------------
=finish
This program was inspired by a failing test in <./t/08-performance/99-misc.t>
"This is Rakudo version 2019.03.1-422-g672fd6e2c built on MoarVM version 2019.05-11-g248e2980a implementing Perl 6.d."
(2019-05-21).
I'm on a 32-bit system.
As expected:
▸ foo.p6 65536 65536
65536 : 2147450880 == 2147450880
65536 : 2147450880 == 2147450880
Hmm... 65537 is wrong with a plain sum(), but succeeds with ':wrap' (I
kind of expected the opposite):
▸ foo.p6 65536 65537
65536 : 2147450880 == 2147450880
65537 : 268468224 != 2147516416
Wut? First attempt gets both correct?
▸ foo.p6 65537 65537
65537 : 2147516416 == 2147516416
65537 : 268468224 != 2147516416
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment