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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libquadmath/] [math/] [scalbnq.c] - Blame information for rev 848

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

Line No. Rev Author Line
1 740 jeremybenn
/* s_scalbnl.c -- long double version of s_scalbn.c.
2
 * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz.
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 "quadmath-imp.h"
17
 
18
static const __float128
19
two114 = 2.0769187434139310514121985316880384E+34Q, /* 0x4071000000000000, 0 */
20
twom114 = 4.8148248609680896326399448564623183E-35Q, /* 0x3F8D000000000000, 0 */
21
huge   = 1.0E+4900Q,
22
tiny   = 1.0E-4900Q;
23
 
24
__float128
25
scalbnq (__float128 x, int n)
26
{
27
        int64_t k,hx,lx;
28
        GET_FLT128_WORDS64(hx,lx,x);
29
        k = (hx>>48)&0x7fff;            /* extract exponent */
30
        if (k==0) {                              /* 0 or subnormal x */
31
            if ((lx|(hx&0x7fffffffffffffffULL))==0) return x; /* +-0 */
32
            x *= two114;
33
            GET_FLT128_MSW64(hx,x);
34
            k = ((hx>>48)&0x7fff) - 114;
35
        }
36
        if (k==0x7fff) return x+x;              /* NaN or Inf */
37
        k = k+n;
38
        if (n> 50000 || k > 0x7ffe)
39
          return huge*copysignq(huge,x); /* overflow  */
40
        if (n< -50000) return tiny*copysignq(tiny,x); /*underflow*/
41
        if (k > 0)                               /* normal result */
42
            {SET_FLT128_MSW64(x,(hx&0x8000ffffffffffffULL)|(k<<48)); return x;}
43
        if (k <= -114)
44
          return tiny*copysignq(tiny,x);        /*underflow*/
45
        k += 114;                               /* subnormal result */
46
        SET_FLT128_MSW64(x,(hx&0x8000ffffffffffffULL)|(k<<48));
47
        return x*twom114;
48
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.