OSDN Git Service

mkostemp: fix implementation
[uclinux-h8/uClibc.git] / libm / s_logb.c
1 /*
2  * ====================================================
3  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
4  *
5  * Developed at SunPro, a Sun Microsystems, Inc. business.
6  * Permission to use, copy, modify, and distribute this
7  * software is freely granted, provided that this notice
8  * is preserved.
9  * ====================================================
10  */
11
12 /*
13  * double logb(x)
14  * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
15  * Use ilogb instead.
16  */
17
18 #include "math.h"
19 #include "math_private.h"
20
21 double logb(double x)
22 {
23         int32_t lx,ix;
24         EXTRACT_WORDS(ix,lx,x);
25         ix &= 0x7fffffff;                       /* high |x| */
26         if((ix|lx)==0) return -1.0/fabs(x);
27         if(ix>=0x7ff00000) return x*x;
28         if((ix>>=20)==0)                        /* IEEE 754 logb */
29                 return -1022.0;
30         else
31                 return (double) (ix-1023);
32 }
33 libm_hidden_def(logb)