-
-
Save lucs/9bf69520a94f8472fdaed4cdcb451973 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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