base/math/s_frexp.c

Go to the documentation of this file.
00001 #if !defined(__ppc__) 00002 /* @(#)s_frexp.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_frexp.c,v 1.9 1995/05/10 20:47:24 jtc Exp $"; 00016 #endif 00017 00018 /* 00019 * for non-zero x 00020 * x = frexp(arg,&exp); 00021 * return a double fp quantity x such that 0.5 <= |x| <1.0 00022 * and the corresponding binary exponent "exp". That is 00023 * arg = x*2^exp. 00024 * If arg is inf, 0.0, or NaN, then frexp(arg,&exp) returns arg 00025 * with *exp=0. 00026 */ 00027 00028 #include "math.h" 00029 #include "mathP.h" 00030 00031 #ifdef __STDC__ 00032 static const double 00033 #else 00034 static double 00035 #endif 00036 two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */ 00037 00038 #ifdef __STDC__ 00039 double frexp(double x, int *eptr) 00040 #else 00041 double frexp(x, eptr) 00042 double x; int *eptr; 00043 #endif 00044 { 00045 int32_t hx, ix, lx; 00046 EXTRACT_WORDS(hx,lx,x); 00047 ix = 0x7fffffff&hx; 00048 *eptr = 0; 00049 if(ix>=0x7ff00000||((ix|lx)==0)) return x; /* 0,inf,nan */ 00050 if (ix<0x00100000) { /* subnormal */ 00051 x *= two54; 00052 GET_HIGH_WORD(hx,x); 00053 ix = hx&0x7fffffff; 00054 *eptr = -54; 00055 } 00056 *eptr += (ix>>20)-1022; 00057 hx = (hx&0x800fffff)|0x3fe00000; 00058 SET_HIGH_WORD(x,hx); 00059 return x; 00060 } 00061 #endif /* !__ppc__ */

Generated on Thu Nov 20 11:49:52 2008 for RTAI API by doxygen 1.3.8