Subversion Repositories Kolibri OS

Rev

Rev 4872 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
/* wrf_gamma.c -- float version of wr_gamma.c.
2
 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3
 */
4
 
5
/*
6
 * ====================================================
7
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8
 *
9
 * Developed at SunPro, a Sun Microsystems, Inc. business.
10
 * Permission to use, copy, modify, and distribute this
11
 * software is freely granted, provided that this notice
12
 * is preserved.
13
 * ====================================================
14
 */
15
 
16
/*
17
 * wrapper float gammaf_r(float x, int *signgamp)
18
 */
19
 
20
#include "fdlibm.h"
21
#include 
22
 
23
#ifdef __STDC__
24
	float gammaf_r(float x, int *signgamp) /* wrapper lgammaf_r */
25
#else
26
	float gammaf_r(x,signgamp)              /* wrapper lgammaf_r */
27
	float x; int *signgamp;
28
#endif
29
{
30
#ifdef _IEEE_LIBM
31
	return __ieee754_gammaf_r(x,signgamp);
32
#else
33
        float y;
34
	struct exception exc;
35
        y = __ieee754_gammaf_r(x,signgamp);
36
        if(_LIB_VERSION == _IEEE_) return y;
37
        if(!finitef(y)&&finitef(x)) {
38
#ifndef HUGE_VAL
39
#define HUGE_VAL inf
40
	    double inf = 0.0;
41
 
42
	    SET_HIGH_WORD(inf,0x7ff00000);	/* set inf to infinite */
43
#endif
44
	    exc.name = "gammaf";
45
	    exc.err = 0;
46
	    exc.arg1 = exc.arg2 = (double)x;
47
            if (_LIB_VERSION == _SVID_)
48
                exc.retval = HUGE;
49
            else
50
                exc.retval = HUGE_VAL;
51
            if(floorf(x)==x&&x<=(float)0.0) {
52
		/* gammaf(-integer) or gamma(0) */
53
		exc.type = SING;
54
		if (_LIB_VERSION == _POSIX_)
55
		  errno = EDOM;
56
		else if (!matherr(&exc)) {
57
		  errno = EDOM;
58
		}
59
            } else {
60
		/* gammaf(finite) overflow */
61
		exc.type = OVERFLOW;
62
                if (_LIB_VERSION == _POSIX_)
63
		  errno = ERANGE;
64
                else if (!matherr(&exc)) {
65
                  errno = ERANGE;
66
                }
67
            }
68
	    if (exc.err != 0)
69
	       errno = exc.err;
70
	    return (float)exc.retval;
71
        } else
72
            return y;
73
#endif
74
}