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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libm/] [math/] [w_scalb.c] - Blame information for rev 862

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

Line No. Rev Author Line
1 207 jeremybenn
 
2
/* @(#)w_scalb.c 5.1 93/09/24 */
3
/*
4
 * ====================================================
5
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6
 *
7
 * Developed at SunPro, a Sun Microsystems, Inc. business.
8
 * Permission to use, copy, modify, and distribute this
9
 * software is freely granted, provided that this notice
10
 * is preserved.
11
 * ====================================================
12
 */
13
 
14
/*
15
 * wrapper scalb(double x, double fn) is provide for
16
 * passing various standard test suite. One
17
 * should use scalbn() instead.
18
 */
19
 
20
#include "fdlibm.h"
21
#include <errno.h>
22
 
23
#ifndef _DOUBLE_IS_32BITS
24
 
25
#ifdef __STDC__
26
#ifdef _SCALB_INT
27
        double scalb(double x, int fn)          /* wrapper scalb */
28
#else
29
        double scalb(double x, double fn)       /* wrapper scalb */
30
#endif
31
#else
32
        double scalb(x,fn)                      /* wrapper scalb */
33
#ifdef _SCALB_INT
34
        double x; int fn;
35
#else
36
        double x,fn;
37
#endif
38
#endif
39
{
40
#ifdef _IEEE_LIBM
41
        return __ieee754_scalb(x,fn);
42
#else
43
        double z;
44
#ifndef HUGE_VAL 
45
#define HUGE_VAL inf
46
        double inf = 0.0;
47
 
48
        SET_HIGH_WORD(inf,0x7ff00000);  /* set inf to infinite */
49
#endif
50
        struct exception exc;
51
        z = __ieee754_scalb(x,fn);
52
        if(_LIB_VERSION == _IEEE_) return z;
53
        if(!(finite(z)||isnan(z))&&finite(x)) {
54
            /* scalb overflow; SVID also returns +-HUGE_VAL */
55
            exc.type = OVERFLOW;
56
            exc.name = "scalb";
57
            exc.err = 0;
58
            exc.arg1 = x;
59
            exc.arg2 = fn;
60
            exc.retval = x > 0.0 ? HUGE_VAL : -HUGE_VAL;
61
            if (_LIB_VERSION == _POSIX_)
62
               errno = ERANGE;
63
            else if (!matherr(&exc)) {
64
               errno = ERANGE;
65
            }
66
            if (exc.err != 0)
67
               errno = exc.err;
68
            return exc.retval;
69
        }
70
        if(z==0.0&&z!=x) {
71
            /* scalb underflow */
72
            exc.type = UNDERFLOW;
73
            exc.name = "scalb";
74
            exc.err = 0;
75
            exc.arg1 = x;
76
            exc.arg2 = fn;
77
            exc.retval = copysign(0.0,x);
78
            if (_LIB_VERSION == _POSIX_)
79
               errno = ERANGE;
80
            else if (!matherr(&exc)) {
81
               errno = ERANGE;
82
            }
83
            if (exc.err != 0)
84
               errno = exc.err;
85
            return exc.retval;
86
        }
87
#ifndef _SCALB_INT
88
        if(!finite(fn)) errno = ERANGE;
89
#endif
90
        return z;
91
#endif 
92
}
93
 
94
#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.