Skip Menu |
Report information
Id: 125524
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: brad <b2gills [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: exponentiation overflows to 0 under MoarVM
Download (untitled) / with headers
text/plain 286b
$ perl6-m -e 'say 10 ** 10 ** 10' 0 While it does come to the conclusion very quickly, the result doesn't make any sense. The JVM backend at least returns a sensible value, even if it does take quite a bit longer to figure out. $ perl6-j -e 'say 10 ** 10 ** 10' Inf
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 686b
On Wed, 01 Jul 2015 13:22:39 -0700, brad wrote: Show quoted text
> > $ perl6-m -e 'say 10 ** 10 ** 10' > 0 > > While it does come to the conclusion very quickly, the result doesn't > make any sense. > > The JVM backend at least returns a sensible value, even if it does > take > quite a bit longer to figure out. > > $ perl6-j -e 'say 10 ** 10 ** 10' > Inf
This now throws on MoarVM, but on JVM still gives Inf.... Does the result need to be the same? <ZoffixW> r: say 10 ** 10000000000 <camelia> rakudo-moar b5aa3c: OUTPUT«Numeric overflow␤ in block <unit> at <tmp> line 1␤␤Actually thrown at:␤ in block <unit> at <tmp> line 1␤␤» <camelia> ..rakudo-jvm 76b061: OUTPUT«Inf␤»
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 2.2k
On Fri, 18 Nov 2016 10:20:43 -0800, cpan@zoffix.com wrote: Show quoted text
> On Wed, 01 Jul 2015 13:22:39 -0700, brad wrote:
> > > > $ perl6-m -e 'say 10 ** 10 ** 10' > > 0 > > > > While it does come to the conclusion very quickly, the result doesn't > > make any sense. > > > > The JVM backend at least returns a sensible value, even if it does > > take > > quite a bit longer to figure out. > > > > $ perl6-j -e 'say 10 ** 10 ** 10' > > Inf
> > This now throws on MoarVM, but on JVM still gives Inf.... Does the > result need to be the same? > > <ZoffixW> r: say 10 ** 10000000000 > <camelia> rakudo-moar b5aa3c: OUTPUT«Numeric overflow␤ in block > <unit> at <tmp> line 1␤␤Actually thrown at:␤ in block <unit> at <tmp> > line 1␤␤» > <camelia> ..rakudo-jvm 76b061: OUTPUT«Inf␤»
Actually, I spot more inconsistencies between the way our math ops behave. For example `*` returns Inf instead of throwing on overflow. So does the `**` on other numerics, BUT it throws on underflow instead, but the Int `**` just gives the division-by-zero error: IRC: https://irclog.perlgeek.de/perl6-dev/2016-11-18#i_13591836 18:17 viki r: say 10 ** 10 ** 10 18:17 camelia rakudo-jvm 76b061: OUTPUT«Inf␤» 18:17 ..rakudo-moar b5aa3c: OUTPUT«Numeric overflow␤ in block <unit> at <tmp> line 1␤␤Actually thrown at:␤ in block <unit> at <tmp> line 1␤␤» 18:22 viki m: say 1e200 * 10e200 18:22 camelia rakudo-moar b5aa3c: OUTPUT«Inf␤» 18:23 viki Seems like it'd make sense to return Inf instead of throwing for ** too? 18:23 And that would align the results between JVM and MoarVM too 18:25 m: say 10e0 ** 10000000000e0 18:25 camelia rakudo-moar b5aa3c: OUTPUT«Inf␤» 18:25 viki :) 18:26 m: say <10/1> ** <10000000000/1> 18:26 camelia rakudo-moar b5aa3c: OUTPUT«Inf␤» 18:28 viki oh heh and in the Num case we throw for Underflow instead 18:28 m: say 10e0 ** -10000000000e0 18:28 camelia rakudo-moar b5aa3c: OUTPUT«Numeric underflow␤ in block <unit> at <tmp> line 1␤␤Actually thrown at:␤ in block <unit> at <tmp> line 1␤␤» 18:28 viki m: say 10 ** -10000000000 18:28 camelia rakudo-moar b5aa3c: OUTPUT«Attempt to divide 1 by zero using div␤ in block <unit> at <tmp> line 1␤␤Actually thrown at:␤ in block <unit> at <tmp> line 1␤␤»


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org