Last change
on this file since 466 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.2 KB
|
Line | |
---|
1 | /* @(#)w_gamma.c 5.1 93/09/24 */ |
---|
2 | /* |
---|
3 | * ==================================================== |
---|
4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
---|
5 | * |
---|
6 | * Developed at SunPro, a Sun Microsystems, Inc. business. |
---|
7 | * Permission to use, copy, modify, and distribute this |
---|
8 | * software is freely granted, provided that this notice |
---|
9 | * is preserved. |
---|
10 | * ==================================================== |
---|
11 | */ |
---|
12 | |
---|
13 | /* double gamma(double x) |
---|
14 | * Return the logarithm of the Gamma function of x or the Gamma function of x, |
---|
15 | * depending on the library mode. |
---|
16 | */ |
---|
17 | |
---|
18 | #include <math.h> |
---|
19 | #include <errno.h> |
---|
20 | |
---|
21 | #ifdef __STDC__ |
---|
22 | double tgamma(double x) |
---|
23 | #else |
---|
24 | double tgamma(x) |
---|
25 | double x; |
---|
26 | #endif |
---|
27 | { |
---|
28 | double y; |
---|
29 | int local_signgam; |
---|
30 | y = gamma_r(x,&local_signgam); |
---|
31 | if (local_signgam < 0) y = -y; |
---|
32 | #ifdef _IEEE_LIBM |
---|
33 | return y; |
---|
34 | #else |
---|
35 | if(_LIB_VERSION == _IEEE_) return y; |
---|
36 | |
---|
37 | if(!finite(y)&&finite(x)) { |
---|
38 | if(floor(x)==x&&x<=0.0) |
---|
39 | { |
---|
40 | /* tgamma pole */ |
---|
41 | errno = EDOM; |
---|
42 | return HUGE_VAL; |
---|
43 | } |
---|
44 | else |
---|
45 | { |
---|
46 | /* tgamma overflow */ |
---|
47 | errno = ERANGE; |
---|
48 | return HUGE_VAL; |
---|
49 | } |
---|
50 | } |
---|
51 | return y; |
---|
52 | #endif |
---|
53 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.