Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exponentiation overflows to 0 under MoarVM #4372

Open
p6rt opened this issue Jul 1, 2015 · 4 comments
Open

exponentiation overflows to 0 under MoarVM #4372

p6rt opened this issue Jul 1, 2015 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jul 1, 2015

Migrated from rt.perl.org#125524 (status was 'open')

Searchable as RT125524$

@p6rt
Copy link
Author

p6rt commented Jul 1, 2015

From @b2gills

  $ 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

@p6rt
Copy link
Author

p6rt commented Nov 18, 2016

From @zoffixznet

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␤»

@p6rt
Copy link
Author

p6rt commented Nov 18, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Nov 18, 2016

From @zoffixznet

On Fri, 18 Nov 2016 10​:20​:43 -0800, cpan@​zoffix.com wrote​:

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␤␤»

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant