Back to index

glibc  2.9
s_frexpf.c
Go to the documentation of this file.
00001 /* s_frexpf.c -- float version of s_frexp.c.
00002  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
00003  */
00004 
00005 /*
00006  * ====================================================
00007  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00008  *
00009  * Developed at SunPro, a Sun Microsystems, Inc. business.
00010  * Permission to use, copy, modify, and distribute this
00011  * software is freely granted, provided that this notice 
00012  * is preserved.
00013  * ====================================================
00014  */
00015 
00016 #if defined(LIBM_SCCS) && !defined(lint)
00017 static char rcsid[] = "$NetBSD: s_frexpf.c,v 1.5 1995/05/10 20:47:26 jtc Exp $";
00018 #endif
00019 
00020 #include "math.h"
00021 #include "math_private.h"
00022 
00023 #ifdef __STDC__
00024 static const float
00025 #else
00026 static float
00027 #endif
00028 two25 =  3.3554432000e+07; /* 0x4c000000 */
00029 
00030 #ifdef __STDC__
00031        float __frexpf(float x, int *eptr)
00032 #else
00033        float __frexpf(x, eptr)
00034        float x; int *eptr;
00035 #endif
00036 {
00037        int32_t hx,ix;
00038        GET_FLOAT_WORD(hx,x);
00039        ix = 0x7fffffff&hx;
00040        *eptr = 0;
00041        if(ix>=0x7f800000||(ix==0)) return x;     /* 0,inf,nan */
00042        if (ix<0x00800000) {        /* subnormal */
00043            x *= two25;
00044            GET_FLOAT_WORD(hx,x);
00045            ix = hx&0x7fffffff;
00046            *eptr = -25;
00047        }
00048        *eptr += (ix>>23)-126;
00049        hx = (hx&0x807fffff)|0x3f000000;
00050        SET_FLOAT_WORD(x,hx);
00051        return x;
00052 }
00053 weak_alias (__frexpf, frexpf)