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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 148 jeremybenn
/* wf_sqrt.c -- float version of w_sqrt.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 sqrtf(x)
18
 */
19
 
20
#include "fdlibm.h"
21
#include <errno.h>
22
 
23
#ifdef __STDC__
24
        float sqrtf(float x)            /* wrapper sqrtf */
25
#else
26
        float sqrtf(x)                  /* wrapper sqrtf */
27
        float x;
28
#endif
29
{
30
#ifdef _IEEE_LIBM
31
        return __ieee754_sqrtf(x);
32
#else
33
        float z;
34
        struct exception exc;
35
        z = __ieee754_sqrtf(x);
36
        if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z;
37
        if(x<(float)0.0) {
38
            /* sqrtf(negative) */
39
            exc.type = DOMAIN;
40
            exc.name = "sqrtf";
41
            exc.err = 0;
42
            exc.arg1 = exc.arg2 = (double)x;
43
            if (_LIB_VERSION == _SVID_)
44
              exc.retval = 0.0;
45
            else
46
              exc.retval = 0.0/0.0;
47
            if (_LIB_VERSION == _POSIX_)
48
              errno = EDOM;
49
            else if (!matherr(&exc)) {
50
              errno = EDOM;
51
            }
52
            if (exc.err != 0)
53
              errno = exc.err;
54
            return (float)exc.retval;
55
        } else
56
            return z;
57
#endif
58
}
59
 
60
#ifdef _DOUBLE_IS_32BITS
61
 
62
#ifdef __STDC__
63
        double sqrt(double x)
64
#else
65
        double sqrt(x)
66
        double x;
67
#endif
68
{
69
        return (double) sqrtf((float) x);
70
}
71
 
72
#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.