Subversion Repositories Kolibri OS

Rev

Rev 4872 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
 
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
 
14
 * wrapper double gamma_r(double x, int *signgamp)
15
 */
16
17
 
18
#include 
19
20
 
21
22
 
23
	double gamma_r(double x, int *signgamp) /* wrapper lgamma_r */
24
#else
25
	double gamma_r(x,signgamp)              /* wrapper lgamma_r */
26
	double x; int *signgamp;
27
#endif
28
{
29
#ifdef _IEEE_LIBM
30
	return __ieee754_gamma_r(x,signgamp);
31
#else
32
        double y;
33
	struct exception exc;
34
        y = __ieee754_gamma_r(x,signgamp);
35
        if(_LIB_VERSION == _IEEE_) return y;
36
        if(!finite(y)&&finite(x)) {
37
#ifndef HUGE_VAL
38
#define HUGE_VAL inf
39
	    double inf = 0.0;
40
41
 
42
#endif
43
	    exc.name = "gamma";
44
	    exc.err = 0;
45
	    exc.arg1 = exc.arg2 = (double)x;
46
            if (_LIB_VERSION == _SVID_)
47
                exc.retval = HUGE;
48
            else
49
                exc.retval = HUGE_VAL;
50
            if(floor(x)==x&&x<=0.0) {
51
		/* gamma(-integer) or gamma(0) */
52
		exc.type = SING;
53
		if (_LIB_VERSION == _POSIX_)
54
		  errno = EDOM;
55
		else if (!matherr(&exc)) {
56
		  errno = EDOM;
57
		}
58
            } else {
59
		/* gamma(finite) overflow */
60
		exc.type = OVERFLOW;
61
                if (_LIB_VERSION == _POSIX_)
62
		  errno = ERANGE;
63
                else if (!matherr(&exc)) {
64
                  errno = ERANGE;
65
                }
66
            }
67
	    if (exc.err != 0)
68
	       errno = exc.err;
69
	    return exc.retval;
70
        } else
71
            return y;
72
#endif
73
}
74
75
 
76