Skip to content

Fix power of 0 and 1 issues in Rational#2616

Merged
enebo merged 1 commit intojruby:masterfrom
lumeet:rational_zero_division
May 1, 2015
Merged

Fix power of 0 and 1 issues in Rational#2616
enebo merged 1 commit intojruby:masterfrom
lumeet:rational_zero_division

Conversation

@lumeet
Copy link
Contributor

@lumeet lumeet commented Feb 23, 2015

The patch adds special case handling for 0**n and 1**n to match the
MRI behavior. For example, the following cases are affected:

0**Rational(1, 2) # => 0/1 instead of 0.0
0**Rational(-1, 2) # => ZeroDivisionError instead of Infinity`
1**Rational(1, 2) # => 1/1 instead of 1.0

The patch adds special case handling for 0**n and 1**n to match the
MRI behavior. For example, the following cases are affected:

0**Rational(1, 2) # => 0/1 instead of 0.0
0**Rational(-1, 2) # => ZeroDivisionError instead of Infinity
1**Rational(1, 2) # => 1/1 instead of 1.0
@enebo enebo added this to the JRuby 9.0.0.0.rc1 milestone May 1, 2015
enebo added a commit that referenced this pull request May 1, 2015
Fix power of 0 and 1 issues in Rational
@enebo enebo merged commit 446f058 into jruby:master May 1, 2015
@lumeet lumeet deleted the rational_zero_division branch May 1, 2015 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants