Skip to content

Commit

Permalink
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions spec/std/math_spec.cr
Original file line number Diff line number Diff line change
@@ -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

4 changes: 2 additions & 2 deletions src/math/math.cr
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ module Math

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

# Calculates the logarithmic gamma of *value*.
@@ -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) %}

0 comments on commit fc35eea

Please sign in to comment.