OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libm/] [common/] [sf_scalbln.c] - Blame information for rev 617

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

Line No. Rev Author Line
1 207 jeremybenn
/* s_scalbnf.c -- float version of s_scalbn.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
#include "fdlibm.h"
17
 
18
#ifdef __STDC__
19
static const float
20
#else
21
static float
22
#endif
23
two25   =  3.355443200e+07,     /* 0x4c000000 */
24
twom25  =  2.9802322388e-08,    /* 0x33000000 */
25
huge   = 1.0e+30,
26
tiny   = 1.0e-30;
27
 
28
#ifdef __STDC__
29
        float scalblnf (float x, long int n)
30
#else
31
        float scalblnf (x,n)
32
        float x; long int n;
33
#endif
34
{
35
        __int32_t k,ix;
36
        GET_FLOAT_WORD(ix,x);
37
        k = (ix&0x7f800000)>>23;                /* extract exponent */
38
        if (k==0) {                              /* 0 or subnormal x */
39
            if ((ix&0x7fffffff)==0) return x; /* +-0 */
40
            x *= two25;
41
            GET_FLOAT_WORD(ix,x);
42
            k = ((ix&0x7f800000)>>23) - 25;
43
            }
44
        if (k==0xff) return x+x;                /* NaN or Inf */
45
        k = k+n;
46
        if (n> 50000 || k >  0xfe)
47
          return huge*copysignf(huge,x); /* overflow  */
48
        if (n< -50000)
49
          return tiny*copysignf(tiny,x);        /*underflow*/
50
        if (k > 0)                               /* normal result */
51
            {SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;}
52
        if (k <= -25)
53
            return tiny*copysignf(tiny,x);      /*underflow*/
54
        k += 25;                                /* subnormal result */
55
        SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23));
56
        return x*twom25;
57
}
58
 
59
#ifdef _DOUBLE_IS_32BITS
60
 
61
#ifdef __STDC__
62
        double scalbln (double x, long int n)
63
#else
64
        double scalbln (x,n)
65
        double x; long int n;
66
#endif
67
{
68
        return (double) scalblnf((float) x, n);
69
}
70
 
71
#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.