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

modulo on natives with negative values are wrong #4999

Open
p6rt opened this issue Jan 5, 2016 · 4 comments
Open

modulo on natives with negative values are wrong #4999

p6rt opened this issue Jan 5, 2016 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jan 5, 2016

Migrated from rt.perl.org#127168 (status was 'new')

Searchable as RT127168$

@p6rt
Copy link
Author

p6rt commented Jan 5, 2016

From @lizmat

[12​:40​:37] <lizmat> m​: my int $a = -10; say $a % 12 # wrong
[12​:40​:38] <+camelia> rakudo-moar d1ff73​: OUTPUT«-10␤»
[12​:40​:46] <lizmat> m​: my Int $a = -10; say $a % 12 # right
[12​:40​:46] <+camelia> rakudo-moar d1ff73​: OUTPUT«2␤»

This is the source of RT #​127161

Liz

@p6rt
Copy link
Author

p6rt commented Jun 4, 2016

From @masak

<masak> this may sound outrageous, but I think I've just uncovered a
bug in Rakudo
<masak> m​: my $x = 0; my $y = ($x - 1) % 8; say $y
<camelia> rakudo-moar 48fe6a​: OUTPUT«7␤»
<masak> m​: my int $x = 0; my $y = ($x - 1) % 8; say $y
<camelia> rakudo-moar 48fe6a​: OUTPUT«-1␤»
<RabidGravy> well that's definitely "special"
* masak submits rakudobug

My expectation is for that second eval to also yield 7. In other
words, the outcome of the modulo calculation shouldn't change just
because $x is a native int.

@p6rt
Copy link
Author

p6rt commented Jun 4, 2016

From @lizmat

On 04 Jun 2016, at 12​:11, Carl Mäsak (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by "Carl Mäsak"
# Please include the string​: [perl #​128318]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=128318 >

<masak> this may sound outrageous, but I think I've just uncovered a
bug in Rakudo
<masak> m​: my $x = 0; my $y = ($x - 1) % 8; say $y
<camelia> rakudo-moar 48fe6a​: OUTPUT«7␤»
<masak> m​: my int $x = 0; my $y = ($x - 1) % 8; say $y
<camelia> rakudo-moar 48fe6a​: OUTPUT«-1␤»
<RabidGravy> well that's definitely "special"
* masak submits rakudobug

My expectation is for that second eval to also yield 7. In other
words, the outcome of the modulo calculation shouldn't change just
because $x is a native int.

$ perl6 -e 'use nqp; say nqp​::mod_i(-1,8); say nqp​::mod_I(-1,8,Int)’
-1
7

*if* this is a bug, it is a bug in the underlying nqp​::mod_i implementation.

Liz

@p6rt
Copy link
Author

p6rt commented Jun 4, 2016

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

@lizmat lizmat changed the title module on natives with negative values are wrong modulo on natives with negative values are wrong Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant