Carl MXXsak (via RT) wrote:
> # New Ticket Created by  "Carl Mäsak" 
> # Please include the string:  [perl #69182]
> # in the subject line of all future correspondence about this issue. 
> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=69182 >
> 
> 
> This be Rakudo b29506, under Parrot r41289.
> 
> $ perl6 -e 'my $d = 2; my $p = 1; while 1 { say $p *= ($d-1)/($d); $d *= 2 }'
> 0.5
> 0.375
> 0.328125
> 0.3076171875
> 0.298004150390625
> 0.293347835540771
> 0.291056055575609
> too many arguments passed (3) - 1 param expected
> in sub infix:* (src/gen_setting.pm:1046)
> 
> Note that if the multiplication makes it through the first few
> multiplication, there's no reason it shouldn't be able to keep going.
> Something's wrong somewhere in them thar internals, it seems.

If you output .perl of these numbers, you see why:

$ perl6 -e 'my $d = 2; my $p = 1; while 1 { say ($p *=
($d-1)/($d)).perl; $d *= 2 }'
1/2
3/8
21/64
315/1024
9765/32768
615195/2097152
78129765/268435456
too many arguments passed (3) - 1 param expected
in sub infix:* (src/gen_setting.pm:1093)
called from Main (<unknown>:1)

Looking at the denominators:

octave:5> log2(2097152)
ans = 21
octave:6> log2(268435456)
ans = 28

The next denominator is 2**36 -> integer overflow, it seems.

A workaround is to call .Num on the RHS of the multiplication, forcing
floats to be used.

Cheers,
Moritz

Reply via email to