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 with negative numbers doesn't work right anymore in Rakudo #2603

Closed
p6rt opened this issue Jan 3, 2012 · 5 comments
Closed

Modulo with negative numbers doesn't work right anymore in Rakudo #2603

p6rt opened this issue Jan 3, 2012 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 3, 2012

Migrated from rt.perl.org#107492 (status was 'resolved')

Searchable as RT107492$

@p6rt
Copy link
Author

p6rt commented Jan 3, 2012

From @masak

<az5112> printf "%d\n", (9 % (-9)) produces -9 in rakudo -- is this a bug?
<masak> az5112​: was just going to eval that :)
<masak> az5112​: welcome ;)
<masak> nom​: say 9 % -9
<p6eval> nom ea0311​: OUTPUT«0␤»
<masak> nom​: say (9 % (-9))
<p6eval> nom ea0311​: OUTPUT«-9␤»
<masak> hm.
<masak> why do those two even differ?
<masak> so the result should still be 0, right?
<TimToady> masak​: sure, looks like a nom bug to me
* masak submits rakudobug
<TimToady> nom​: say 0 % (-9)
<p6eval> nom ea0311​: OUTPUT«-9␤»
<masak> b​: say 9 % -9; say 9 % (-9)
<p6eval> b 1b7dd1​: OUTPUT«0␤0␤»
<masak> yep. definitely a bug.
<masak> az5112++
<masak> az5112​: I'm always very happy when p6cc contestants catch bugs for us :)

Looking at it more closely, I see both a parsing bug and an arithmetic bug here.

* Parsing bug​: C<9 % -9> differs from C<9 % (-9)>. It shouldn't.
* Arithmetic bug​: C<9 % (-9)> yields -9 rather than the correct
answer, 0. -9 is even outside of the range of *possible* values for
C<$x % (-9)>.

@p6rt
Copy link
Author

p6rt commented Jan 8, 2012

From @moritz

The arithmetic bug has been fixed in 2011.12-44-g13f3e6d, tests are in
S03-operators/arith.t. I have no idea about the parsing bug though.

@p6rt
Copy link
Author

p6rt commented Jan 8, 2012

@moritz - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 4, 2013

From @moritz

The parsing bug has also been fixed.

@p6rt
Copy link
Author

p6rt commented Jan 4, 2013

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jan 4, 2013
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant