Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix #4223: Fixed undefined method Math.gamma (#4229)
  • Loading branch information
KCreate authored and bcardiff committed Apr 3, 2017
1 parent a36e2b4 commit fc35eea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions spec/std/math_spec.cr
Expand Up @@ -192,11 +192,15 @@ describe "Math" do
it "gamma" do
Math.gamma(3.2_f32).should be_close(2.4239654799353683, 1e-6)
Math.gamma(3.2).should be_close(2.4239654799353683, 1e-7)
Math.gamma(5).should eq 24
Math.gamma(5_i8).should eq 24
end

it "lgamma" do
Math.lgamma(2.96_f32).should be_close(0.6565534110944214, 1e-7)
Math.lgamma(2.96).should be_close(0.6565534110944214, 1e-7)
Math.lgamma(3).should be_close(0.6931471805599454, 1e-7)
Math.lgamma(3_i8).should be_close(0.6931471805599454, 1e-7)
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/math/math.cr
Expand Up @@ -62,7 +62,7 @@ module Math

# ditto
def gamma(value)
LibM.tgamma(value)
gamma(value.to_f)
end

# Calculates the logarithmic gamma of *value*.
Expand All @@ -89,7 +89,7 @@ module Math

# ditto
def lgamma(value)
LibM.gamma(value.to_f)
lgamma(value.to_f)
end

{% for name in %w(atan2 copysign hypot) %}
Expand Down

0 comments on commit fc35eea

Please sign in to comment.