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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 740 jeremybenn
/* s_ilogbl.c -- long double version of s_ilogb.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
#if defined(LIBM_SCCS) && !defined(lint)
17
static char rcsid[] = "$NetBSD: $";
18
#endif
19
 
20
/* ilogbl(long double x)
21
 * return the binary exponent of non-zero x
22
 * ilogbl(0) = FP_ILOGB0
23
 * ilogbl(NaN) = FP_ILOGBNAN (no signal is raised)
24
 * ilogbl(+-Inf) = INT_MAX (no signal is raised)
25
 */
26
 
27
#include <limits.h>
28
#include <math.h>
29
#include "quadmath-imp.h"
30
 
31
#ifndef FP_ILOGB0
32
# define FP_ILOGB0 INT_MIN
33
#endif
34
#ifndef FP_ILOGBNAN
35
# define FP_ILOGBNAN INT_MAX
36
#endif
37
 
38
int
39
ilogbq (__float128 x)
40
{
41
        int64_t hx,lx;
42
        int ix;
43
 
44
        GET_FLT128_WORDS64(hx,lx,x);
45
        hx &= 0x7fffffffffffffffLL;
46
        if(hx <= 0x0001000000000000LL) {
47
            if((hx|lx)==0)
48
                return FP_ILOGB0;       /* ilogbl(0) = FP_ILOGB0 */
49
            else                        /* subnormal x */
50
                if(hx==0) {
51
                    for (ix = -16431; lx>0; lx<<=1) ix -=1;
52
                } else {
53
                    for (ix = -16382, hx<<=15; hx>0; hx<<=1) ix -=1;
54
                }
55
            return ix;
56
        }
57
        else if (hx<0x7fff000000000000LL) return (hx>>48)-0x3fff;
58
        else if (FP_ILOGBNAN != INT_MAX) {
59
            /* ISO C99 requires ilogbl(+-Inf) == INT_MAX.  */
60
            if (((hx^0x7fff000000000000LL)|lx) == 0)
61
                return INT_MAX;
62
        }
63
        return FP_ILOGBNAN;
64
}

powered by: WebSVN 2.1.0

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