fix c6x toolchain compile
[uclibc-ng.git] / libm / s_logb.c
blob9016b9721a58575ab59d9c03d07275871b11de36
1 /*
2 * ====================================================
3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
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 * ====================================================
13 * double logb(x)
14 * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
15 * Use ilogb instead.
18 #include "math.h"
19 #include "math_private.h"
21 double logb(double x)
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);
33 libm_hidden_def(logb)