s_logbf.c revision 153049
12116Sjkh/* s_logbf.c -- float version of s_logb.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 118870Srgrimes * software is freely granted, provided that this notice 122116Sjkh * is preserved. 132116Sjkh * ==================================================== 142116Sjkh */ 152116Sjkh 162116Sjkh#ifndef lint 1750476Speterstatic char rcsid[] = "$FreeBSD: head/lib/msun/src/s_logbf.c 153049 2005-12-03 11:57:19Z bde $"; 182116Sjkh#endif 192116Sjkh 202116Sjkh#include "math.h" 212116Sjkh#include "math_private.h" 222116Sjkh 23153049Sbdestatic const float 24153049Sbdetwo25 = 3.355443200e+07; /* 0x4c000000 */ 25153049Sbde 2697413Salfredfloat 2797413Salfredlogbf(float x) 282116Sjkh{ 292116Sjkh int32_t ix; 302116Sjkh GET_FLOAT_WORD(ix,x); 312116Sjkh ix &= 0x7fffffff; /* high |x| */ 322116Sjkh if(ix==0) return (float)-1.0/fabsf(x); 332116Sjkh if(ix>=0x7f800000) return x*x; 34153049Sbde if(ix<0x00800000) { 35153049Sbde x *= two25; /* convert subnormal x to normal */ 36153049Sbde GET_FLOAT_WORD(ix,x); 37153049Sbde ix &= 0x7fffffff; 38153049Sbde return (float) ((ix>>23)-127-25); 39153049Sbde } else 40153049Sbde return (float) ((ix>>23)-127); 412116Sjkh} 42