base/math/s_logb.c

Go to the documentation of this file.
00001 #if !defined(__ppc__)
00002 /* @(#)s_logb.c 5.1 93/09/24 */
00003 /*
00004  * ====================================================
00005  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00006  *
00007  * Developed at SunPro, a Sun Microsystems, Inc. business.
00008  * Permission to use, copy, modify, and distribute this
00009  * software is freely granted, provided that this notice 
00010  * is preserved.
00011  * ====================================================
00012  */
00013 
00014 #if defined(LIBM_SCCS) && !defined(lint)
00015 static char rcsid[] = "$NetBSD: s_logb.c,v 1.8 1995/05/10 20:47:50 jtc Exp $";
00016 #endif
00017 
00018 /*
00019  * double logb(x)
00020  * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
00021  * Use ilogb instead.
00022  */
00023 
00024 #include "math.h"
00025 #include "mathP.h"
00026 
00027 #ifdef __STDC__
00028     double logb(double x)
00029 #else
00030     double logb(x)
00031     double x;
00032 #endif
00033 {
00034     int32_t lx,ix;
00035     EXTRACT_WORDS(ix,lx,x);
00036     ix &= 0x7fffffff;           /* high |x| */
00037     if((ix|lx)==0) return -1.0/fabs(x);
00038     if(ix>=0x7ff00000) return x*x;
00039     if((ix>>=20)==0)            /* IEEE 754 logb */
00040         return -1022.0; 
00041     else
00042         return (double) (ix-1023); 
00043 }
00044 #endif /* !__ppc__ */

Generated on Tue Feb 2 17:46:05 2010 for RTAI API by  doxygen 1.4.7