diff --git a/spec/std/math_spec.cr b/spec/std/math_spec.cr index fc64e698421d..5855939e33f6 100644 --- a/spec/std/math_spec.cr +++ b/spec/std/math_spec.cr @@ -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 diff --git a/src/math/math.cr b/src/math/math.cr index 904faf16feb7..49a7d45764e6 100644 --- a/src/math/math.cr +++ b/src/math/math.cr @@ -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) %}