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

Subversion Repositories or1k

[/] [or1k/] [branches/] [newlib/] [newlib/] [newlib/] [libm/] [math/] [wf_lgamma.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_lgamma.c -- float version of w_lgamma.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 lgammaf(float x)
22
#else
23
        float lgammaf(x)
24
        float x;
25
#endif
26
{
27
#ifdef _IEEE_LIBM
28
        return __ieee754_lgammaf_r(x,&signgam);
29
#else
30
        float y;
31
        struct exception exc;
32
        y = __ieee754_lgammaf_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
            exc.name = "lgammaf";
42
            if (_LIB_VERSION == _SVID_)
43
               exc.retval = HUGE;
44
            else
45
               exc.retval = HUGE_VAL;
46
            if(floorf(x)==x&&x<=(float)0.0) {
47
                /* lgammaf(-integer) */
48
                exc.type = SING;
49
                if (_LIB_VERSION == _POSIX_)
50
                   errno = EDOM;
51
                else if (!matherr(&exc)) {
52
                   errno = EDOM;
53
                }
54
 
55
            } else {
56
                /* lgammaf(finite) overflow */
57
                exc.type = OVERFLOW;
58
                if (_LIB_VERSION == _POSIX_)
59
                   errno = ERANGE;
60
                else if (!matherr(&exc)) {
61
                   errno = ERANGE;
62
                }
63
            }
64
            if (exc.err != 0)
65
               errno = exc.err;
66
            return (float)exc.retval;
67
        } else
68
            return y;
69
#endif
70
}
71
 
72
#ifdef _DOUBLE_IS_32BITS
73
 
74
#ifdef __STDC__
75
        double lgamma(double x)
76
#else
77
        double lgamma(x)
78
        double x;
79
#endif
80
{
81
        return (double) lgammaf((float) x);
82
}
83
 
84
#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.