mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
math.c: check argument to tgamma
* math.c (math_gamma): check the argument before calling math function `tgamma` for edge cases. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
94a7a4e908
commit
1a4a536247
2 changed files with 7 additions and 2 deletions
|
@ -1317,7 +1317,6 @@ main()
|
|||
ac_cv_func___builtin_setjmp=no
|
||||
ac_cv_func_round=no
|
||||
])
|
||||
ac_cv_func_tgamma=no
|
||||
AC_CHECK_TYPE([NET_LUID], [], [],
|
||||
[@%:@include <winsock2.h>
|
||||
@%:@include <iphlpapi.h>])
|
||||
|
|
8
math.c
8
math.c
|
@ -869,7 +869,13 @@ math_gamma(VALUE unused_obj, VALUE x)
|
|||
double d;
|
||||
d = Get_Double(x);
|
||||
/* check for domain error */
|
||||
if (isinf(d) && signbit(d)) domain_error("gamma");
|
||||
if (isinf(d)) {
|
||||
if (signbit(d)) domain_error("gamma");
|
||||
return DBL2NUM(INFINITY);
|
||||
}
|
||||
if (d == 0.0) {
|
||||
return signbit(d) ? DBL2NUM(-INFINITY) : DBL2NUM(INFINITY);
|
||||
}
|
||||
if (d == floor(d)) {
|
||||
if (d < 0.0) domain_error("gamma");
|
||||
if (1.0 <= d && d <= (double)NFACT_TABLE) {
|
||||
|
|
Loading…
Reference in a new issue