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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libm/] [math/] [wf_gamma.c] - Blame information for rev 855

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

Line No. Rev Author Line
1 148 jeremybenn
/* 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 <reent.h>
19
#include <errno.h>
20
 
21
#ifdef __STDC__
22
        float gammaf(float x)
23
#else
24
        float gammaf(x)
25
        float x;
26
#endif
27
{
28
#ifdef _IEEE_LIBM
29
        return __ieee754_gammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
30
#else
31
        float y;
32
        struct exception exc;
33
        y = __ieee754_gammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
34
        if(_LIB_VERSION == _IEEE_) return y;
35
        if(!finitef(y)&&finitef(x)) {
36
#ifndef HUGE_VAL 
37
#define HUGE_VAL inf
38
            double inf = 0.0;
39
 
40
            SET_HIGH_WORD(inf,0x7ff00000);      /* set inf to infinite */
41
#endif
42
            if(floorf(x)==x&&x<=(float)0.0) {
43
                /* gammaf(-integer) or gammaf(0) */
44
                exc.type = SING;
45
                exc.name = "gammaf";
46
                exc.err = 0;
47
                exc.arg1 = exc.arg2 = (double)x;
48
                if (_LIB_VERSION == _SVID_)
49
                  exc.retval = HUGE;
50
                else
51
                  exc.retval = HUGE_VAL;
52
                if (_LIB_VERSION == _POSIX_)
53
                  errno = EDOM;
54
                else if (!matherr(&exc)) {
55
                  errno = EDOM;
56
                }
57
            } else {
58
                /* gammaf(finite) overflow */
59
                exc.type = OVERFLOW;
60
                exc.name = "gammaf";
61
                exc.err = 0;
62
                exc.arg1 = exc.arg2 = (double)x;
63
                if (_LIB_VERSION == _SVID_)
64
                  exc.retval = HUGE;
65
                else
66
                  exc.retval = HUGE_VAL;
67
                if (_LIB_VERSION == _POSIX_)
68
                  errno = ERANGE;
69
                else if (!matherr(&exc)) {
70
                  errno = ERANGE;
71
                }
72
            }
73
            if (exc.err != 0)
74
               errno = exc.err;
75
            return (float)exc.retval;
76
        } else
77
            return y;
78
#endif
79
}
80
 
81
#ifdef _DOUBLE_IS_32BITS
82
 
83
#ifdef __STDC__
84
        double gamma(double x)
85
#else
86
        double gamma(x)
87
        double x;
88
#endif
89
{
90
        return (double) gammaf((float) x);
91
}
92
 
93
#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.