s_ilogbf.c revision 2116
12116Sjkh/* s_ilogbf.c -- float version of s_ilogb.c. 22116Sjkh * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 32116Sjkh */ 42116Sjkh 52116Sjkh/* 62116Sjkh * ==================================================== 72116Sjkh * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 82116Sjkh * 92116Sjkh * Developed at SunPro, a Sun Microsystems, Inc. business. 102116Sjkh * Permission to use, copy, modify, and distribute this 112116Sjkh * software is freely granted, provided that this notice 122116Sjkh * is preserved. 132116Sjkh * ==================================================== 142116Sjkh */ 152116Sjkh 162116Sjkh#ifndef lint 172116Sjkhstatic char rcsid[] = "$Id: s_ilogbf.c,v 1.2 1994/08/18 23:06:53 jtc Exp $"; 182116Sjkh#endif 192116Sjkh 202116Sjkh#include "math.h" 212116Sjkh#include "math_private.h" 222116Sjkh 232116Sjkh#ifdef __STDC__ 242116Sjkh int ilogbf(float x) 252116Sjkh#else 262116Sjkh int ilogbf(x) 272116Sjkh float x; 282116Sjkh#endif 292116Sjkh{ 302116Sjkh int32_t hx,ix; 312116Sjkh 322116Sjkh GET_FLOAT_WORD(hx,x); 332116Sjkh hx &= 0x7fffffff; 342116Sjkh if(hx<0x00800000) { 352116Sjkh if(hx==0) 362116Sjkh return 0x80000001; /* ilogb(0) = 0x80000001 */ 372116Sjkh else /* subnormal x */ 382116Sjkh for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1; 392116Sjkh return ix; 402116Sjkh } 412116Sjkh else if (hx<0x7f800000) return (hx>>23)-127; 422116Sjkh else return 0x7fffffff; 432116Sjkh} 44