1 /* s_logbf.c -- float version of s_logb.c. 2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 */ 4 5 /* 6 * ==================================================== 7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 * 9 * Developed at SunPro, a Sun Microsystems, Inc. business. 10 * Permission to use, copy, modify, and distribute this 11 * software is freely granted, provided that this notice 12 * is preserved. 13 * ==================================================== 14 */ 15 16 #include <sys/cdefs.h> 17 #if defined(LIBM_SCCS) && !defined(lint) 18 __RCSID("$NetBSD: s_logbf.c,v 1.5 1997/10/09 11:32:51 lukem Exp $"); 19 #endif 20 21 #include "math.h" 22 #include "math_private.h" 23 24 #ifdef __STDC__ 25 float logbf(float x) 26 #else 27 float logbf(x) 28 float x; 29 #endif 30 { 31 int32_t ix; 32 GET_FLOAT_WORD(ix,x); 33 ix &= 0x7fffffff; /* high |x| */ 34 if(ix==0) return (float)-1.0/fabsf(x); 35 if(ix>=0x7f800000) return x*x; 36 if((ix>>=23)==0) /* IEEE 754 logb */ 37 return -126.0; 38 else 39 return (float) (ix-127); 40 } 41