Home | History | Annotate | Download | only in fdlibm
      1 
      2 /* @(#)s_logb.c 1.3 95/01/18 */
      3 /*
      4  * ====================================================
      5  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
      6  *
      7  * Developed at SunSoft, a Sun Microsystems, Inc. business.
      8  * Permission to use, copy, modify, and distribute this
      9  * software is freely granted, provided that this notice
     10  * is preserved.
     11  * ====================================================
     12  */
     13 
     14 /*
     15  * double ieee_logb(x)
     16  * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
     17  * Use ilogb instead.
     18  */
     19 
     20 #include "fdlibm.h"
     21 
     22 #ifdef __STDC__
     23 	double ieee_logb(double x)
     24 #else
     25 	double ieee_logb(x)
     26 	double x;
     27 #endif
     28 {
     29 	int lx,ix;
     30 	ix = (__HI(x))&0x7fffffff;	/* high |x| */
     31 	lx = __LO(x);			/* low x */
     32 	if((ix|lx)==0) return -1.0/ieee_fabs(x);
     33 	if(ix>=0x7ff00000) return x*x;
     34 	if((ix>>=20)==0) 			/* IEEE 754 logb */
     35 		return -1022.0;
     36 	else
     37 		return (double) (ix-1023);
     38 }
     39