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

fix using big rational #**with unsigned ints #10887

Merged
merged 5 commits into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions spec/std/big/big_rational_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ describe BigRational do
result = br(17, 11) ** 5
result.should be_a(BigRational)
result.should eq(br(1419857, 161051))

result = br(17, 11) ** 5_u8
result.should be_a(BigRational)
result.should eq(br(1419857, 161051))
end

it "exponentiates with negative powers" do
Expand Down
2 changes: 1 addition & 1 deletion src/big/big_rational.cr
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ struct BigRational < Number
# ```
def **(other : Int) : BigRational
if other < 0
return (self ** -other).inv
return (self ** other.abs).inv
end
BigRational.new(numerator ** other, denominator ** other)
end
Expand Down