OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libm/] [math/] [wf_gamma.c] - Blame information for rev 39

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/* wf_gamma.c -- float version of w_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
#include "fdlibm.h"
18
#include <errno.h>
19
 
20
#ifdef __STDC__
21
        float gammaf(float x)
22
#else
23
        float gammaf(x)
24
        float x;
25
#endif
26
{
27
#ifdef _IEEE_LIBM
28
        return __ieee754_gammaf_r(x,&signgam);
29
#else
30
        float y;
31
        struct exception exc;
32
        y = __ieee754_gammaf_r(x,&signgam);
33
        if(_LIB_VERSION == _IEEE_) return y;
34
        if(!finitef(y)&&finitef(x)) {
35
#ifndef HUGE_VAL 
36
#define HUGE_VAL inf
37
            double inf = 0.0;
38
 
39
            SET_HIGH_WORD(inf,0x7ff00000);      /* set inf to infinite */
40
#endif
41
            if(floorf(x)==x&&x<=(float)0.0) {
42
                /* gammaf(-integer) or gammaf(0) */
43
                exc.type = SING;
44
                exc.name = "gammaf";
45
                if (_LIB_VERSION == _SVID_)
46
                  exc.retval = HUGE;
47
                else
48
                  exc.retval = HUGE_VAL;
49
                if (_LIB_VERSION == _POSIX_)
50
                  errno = EDOM;
51
                else if (!matherr(&exc)) {
52
                  errno = EDOM;
53
                }
54
            } else {
55
                /* gammaf(finite) overflow */
56
                exc.type = OVERFLOW;
57
                exc.name = "gammaf";
58
                if (_LIB_VERSION == _SVID_)
59
                  exc.retval = HUGE;
60
                else
61
                  exc.retval = HUGE_VAL;
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
}
75
 
76
#ifdef _DOUBLE_IS_32BITS
77
 
78
#ifdef __STDC__
79
        double gamma(double x)
80
#else
81
        double gamma(x)
82
        double x;
83
#endif
84
{
85
        return (double) gammaf((float) x);
86
}
87
 
88
#endif /* defined(_DOUBLE_IS_32BITS) */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.